Class: ForemanApiClient::Host
- Inherits:
-
Object
- Object
- ForemanApiClient::Host
- Defined in:
- lib/foreman_api_client/host.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#manager_ref ⇒ Object
Returns the value of attribute manager_ref.
Instance Method Summary collapse
- #attributes ⇒ Object
- #building? ⇒ Boolean
-
#initialize(connection, manager_ref) ⇒ Host
constructor
A new instance of Host.
-
#power_state(action = "status") ⇒ Object
valid actions are (on/start), (off/stop), (soft/reboot), (cycle/reset), (state/status).
- #powered_off? ⇒ Boolean
- #powered_on? ⇒ Boolean
- #set_boot_mode(mode = "pxe") ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update(params) ⇒ Object
Constructor Details
#initialize(connection, manager_ref) ⇒ Host
Returns a new instance of Host.
6 7 8 9 |
# File 'lib/foreman_api_client/host.rb', line 6 def initialize(connection, manager_ref) @connection = connection @manager_ref = manager_ref end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4 5 6 |
# File 'lib/foreman_api_client/host.rb', line 4 def connection @connection end |
#manager_ref ⇒ Object
Returns the value of attribute manager_ref.
3 4 5 |
# File 'lib/foreman_api_client/host.rb', line 3 def manager_ref @manager_ref end |
Instance Method Details
#attributes ⇒ Object
40 41 42 |
# File 'lib/foreman_api_client/host.rb', line 40 def attributes connection.fetch(:hosts, :show, "id" => manager_ref).first end |
#building? ⇒ Boolean
11 12 13 |
# File 'lib/foreman_api_client/host.rb', line 11 def building? attributes["build"] end |
#power_state(action = "status") ⇒ Object
valid actions are (on/start), (off/stop), (soft/reboot), (cycle/reset), (state/status)
24 25 26 |
# File 'lib/foreman_api_client/host.rb', line 24 def power_state(action = "status") connection.fetch(:hosts, :power, "id" => manager_ref, "power_action" => action).first["power"] end |
#powered_off? ⇒ Boolean
28 29 30 |
# File 'lib/foreman_api_client/host.rb', line 28 def powered_off? power_state == "off" end |
#powered_on? ⇒ Boolean
32 33 34 |
# File 'lib/foreman_api_client/host.rb', line 32 def powered_on? power_state == "on" end |
#set_boot_mode(mode = "pxe") ⇒ Object
36 37 38 |
# File 'lib/foreman_api_client/host.rb', line 36 def set_boot_mode(mode = "pxe") connection.fetch(:hosts, :boot, "id" => manager_ref, "device" => mode).first["boot"] end |
#start ⇒ Object
15 16 17 |
# File 'lib/foreman_api_client/host.rb', line 15 def start power_state("on") end |
#stop ⇒ Object
19 20 21 |
# File 'lib/foreman_api_client/host.rb', line 19 def stop power_state("off") end |
#update(params) ⇒ Object
44 45 46 |
# File 'lib/foreman_api_client/host.rb', line 44 def update(params) connection.fetch(:hosts, :update, "id" => manager_ref, "host" => params) end |