Class: SystemdServiceCheck::Base
- Inherits:
-
Object
- Object
- SystemdServiceCheck::Base
- Defined in:
- lib/systemd_service_check.rb
Overview
Base
Constant Summary
Constants included from Utils
Utils::PROPERTY, Utils::PROPERTY_TO_SNAKE_SYM
Instance Attribute Summary collapse
-
#envs ⇒ Object
readonly
Returns the value of attribute envs.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
-
#target_envs ⇒ Object
readonly
Returns the value of attribute target_envs.
-
#target_servers ⇒ Object
readonly
Returns the value of attribute target_servers.
Instance Method Summary collapse
-
#initialize(envs, yaml, role = nil) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #to_json ⇒ Object
Methods included from SSH
#hostname, #ssh, #systemctl_show
Methods included from Utils
#configure_target_envs, #configure_target_servers, #servers_from
Constructor Details
#initialize(envs, yaml, role = nil) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/systemd_service_check.rb', line 24 def initialize(envs, yaml, role = nil) raise Utils::InvalidOptionError, "Argument `yaml` must not be blank." if blank? yaml @envs = envs || [] @role = role.nil? || role.empty? ? nil : role @servers = servers_from(yaml) @target_envs = configure_target_envs(envs, @servers) @target_servers = configure_target_servers(@servers, @target_envs, @role) @results = [] end |
Instance Attribute Details
#envs ⇒ Object (readonly)
Returns the value of attribute envs.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def envs @envs end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def results @results end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def role @role end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def servers @servers end |
#target_envs ⇒ Object (readonly)
Returns the value of attribute target_envs.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def target_envs @target_envs end |
#target_servers ⇒ Object (readonly)
Returns the value of attribute target_servers.
19 20 21 |
# File 'lib/systemd_service_check.rb', line 19 def target_servers @target_servers end |
Instance Method Details
#run ⇒ Object
35 36 37 |
# File 'lib/systemd_service_check.rb', line 35 def run @results = @target_servers.map { |server| ssh(server) } end |
#to_json ⇒ Object
39 40 41 42 43 44 |
# File 'lib/systemd_service_check.rb', line 39 def to_json @results.map do |result| { server: result.server.to_h, services: result.services.map(&:to_h) } end.to_json end |