Class: Rubyipmi::Freeipmi::Power
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- BaseCommand
- Rubyipmi::Freeipmi::Power
- Defined in:
- lib/rubyipmi/freeipmi/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, #validate_status
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.
4 5 6 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 4 def initialize(opts = ObservableHash.new) super("ipmipower", opts) end |
Instance Method Details
#command(opt) ⇒ Object
The command function is a wrapper that actually calls the run method
9 10 11 12 13 14 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 9 def command(opt) @options[opt] = false value = runcmd @options.delete_notify(opt) return @result end |
#cycle ⇒ Object
Power cycle the system
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 27 def cycle # if the system is off turn it on if off? on else command("cycle") end end |
#off ⇒ Object
Turn off the system
22 23 24 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 22 def off command("off") end |
#off? ⇒ Boolean
Test to see if the power is off
65 66 67 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 65 def off? status == "off" end |
#on ⇒ Object
Turn on the system
17 18 19 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 17 def on command("on") end |
#on? ⇒ Boolean
Test to see if the power is on
60 61 62 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 60 def on? status == "on" end |
#powerInterrupt ⇒ Object
47 48 49 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 47 def powerInterrupt command("pulse") end |
#reset ⇒ Object
Perform a power reset on the system
38 39 40 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 38 def reset command("reset") end |
#softShutdown ⇒ Object
Perform a soft shutdown, like briefly pushing the power button
43 44 45 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 43 def softShutdown command("soft") end |
#status ⇒ Object
Get the power status of the system, will show either on or off
52 53 54 55 56 57 |
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 52 def status value = command("stat") if value @result.split(":").last.chomp.strip end end |