Class: Rubyipmi::Ipmitool::Power
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Ipmitool::Power
- Defined in:
- lib/rubyipmi/ipmitool/commands/power.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
#cmd, #lastcall, #max_retry_count, #options, #passfile, #result
Instance Method Summary collapse
-
#command(opt) ⇒ Object
The command function is a wrapper that actually calls the run method.
-
#cycle ⇒ Object
Power cycle the system.
-
#initialize(opts = ObservableHash.new) ⇒ Power
constructor
A new instance of Power.
-
#off ⇒ Object
Turn off the system.
-
#off? ⇒ Boolean
Test to see if the power is off.
-
#on ⇒ Object
Turn on the system.
-
#on? ⇒ Boolean
Test to see if the power is on.
- #powerInterrupt ⇒ Object
-
#reset ⇒ Object
Perform a power reset on the system.
-
#softShutdown ⇒ Object
Perform a soft shutdown, like briefly pushing the power button.
-
#status ⇒ Object
Get the power status of the system, will show either on or off.
Methods inherited from BaseCommand
#find_fix, #makecommand, #max_retry_count, #setpass
Methods inherited from BaseCommand
#dump_command, #find_fix, #locate_command, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status
Constructor Details
#initialize(opts = ObservableHash.new) ⇒ Power
Returns a new instance of Power.
5 6 7 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 5 def initialize(opts = ObservableHash.new) super("ipmitool", opts) end |
Instance Method Details
#command(opt) ⇒ Object
The command function is a wrapper that actually calls the run method
10 11 12 13 14 15 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 10 def command(opt) @options["cmdargs"] = "power #{opt}" value = runcmd @options.delete_notify("cmdargs") return value end |
#cycle ⇒ Object
Power cycle the system
36 37 38 39 40 41 42 43 44 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 36 def cycle # if the system is off turn it on if off? on else command("cycle") end end |
#off ⇒ Object
Turn off the system
27 28 29 30 31 32 33 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 27 def off if off? return true else command("off") end end |
#off? ⇒ Boolean
Test to see if the power is off
75 76 77 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 75 def off? status == "off" end |
#on ⇒ Object
Turn on the system
18 19 20 21 22 23 24 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 18 def on if on? return true else command("on") end end |
#on? ⇒ Boolean
Test to see if the power is on
69 70 71 72 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 69 def on? status == "on" end |
#powerInterrupt ⇒ Object
56 57 58 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 56 def powerInterrupt command("diag") end |
#reset ⇒ Object
Perform a power reset on the system
47 48 49 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 47 def reset command("reset") end |
#softShutdown ⇒ Object
Perform a soft shutdown, like briefly pushing the power button
52 53 54 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 52 def softShutdown command("soft") end |
#status ⇒ Object
Get the power status of the system, will show either on or off
61 62 63 64 65 66 |
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 61 def status value = command("status") if value @result.match(/(off|on)/).to_s end end |