Class: Pvectl::Models::Service
- Defined in:
- lib/pvectl/models/service.rb
Overview
Represents a Proxmox service running on a node.
Services are system daemons that make up the Proxmox VE platform, such as pveproxy, pvedaemon, pve-cluster, etc.
Instance Attribute Summary collapse
-
#active_state ⇒ String?
readonly
Systemd ActiveState (active, inactive, failed, …).
-
#desc ⇒ String?
readonly
The service description.
-
#name ⇒ String?
readonly
The display name of the service.
-
#node ⇒ String?
readonly
Node name this service belongs to.
-
#service ⇒ String
readonly
The service identifier.
-
#state ⇒ String
readonly
The current state (running, stopped, etc.).
-
#unit_state ⇒ String?
readonly
Systemd UnitFileState (enabled, disabled, masked, …).
Instance Method Summary collapse
-
#display_name ⇒ String
Returns the display name, falling back to service identifier.
-
#initialize(attrs = {}) ⇒ Service
constructor
Creates a new Service instance.
-
#running? ⇒ Boolean
Checks if the service is currently running.
Constructor Details
#initialize(attrs = {}) ⇒ Service
Creates a new Service instance.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pvectl/models/service.rb', line 53 def initialize(attrs = {}) super @service = attributes[:service] @name = attributes[:name] @state = attributes[:state] @desc = attributes[:desc] # Accept both symbol keys (:active_state) and dasherized keys (:"active-state") @active_state = attributes[:active_state] || attributes[:"active-state"] @unit_state = attributes[:unit_state] || attributes[:"unit-state"] @node = attributes[:node] end |
Instance Attribute Details
#active_state ⇒ String? (readonly)
Returns systemd ActiveState (active, inactive, failed, …).
35 36 37 |
# File 'lib/pvectl/models/service.rb', line 35 def active_state @active_state end |
#desc ⇒ String? (readonly)
Returns the service description.
32 33 34 |
# File 'lib/pvectl/models/service.rb', line 32 def desc @desc end |
#name ⇒ String? (readonly)
Returns the display name of the service.
26 27 28 |
# File 'lib/pvectl/models/service.rb', line 26 def name @name end |
#node ⇒ String? (readonly)
Returns node name this service belongs to.
41 42 43 |
# File 'lib/pvectl/models/service.rb', line 41 def node @node end |
#service ⇒ String (readonly)
Returns the service identifier.
23 24 25 |
# File 'lib/pvectl/models/service.rb', line 23 def service @service end |
#state ⇒ String (readonly)
Returns the current state (running, stopped, etc.).
29 30 31 |
# File 'lib/pvectl/models/service.rb', line 29 def state @state end |
#unit_state ⇒ String? (readonly)
Returns systemd UnitFileState (enabled, disabled, masked, …).
38 39 40 |
# File 'lib/pvectl/models/service.rb', line 38 def unit_state @unit_state end |
Instance Method Details
#display_name ⇒ String
Returns the display name, falling back to service identifier.
75 76 77 |
# File 'lib/pvectl/models/service.rb', line 75 def display_name name || service end |
#running? ⇒ Boolean
Checks if the service is currently running.
68 69 70 |
# File 'lib/pvectl/models/service.rb', line 68 def running? state == "running" end |