Class: Rubyipmi::Freeipmi::Power

Inherits:
BaseCommand show all
Includes:
PowerMixin
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

Methods included from PowerMixin

#cycle, #off, #off?, #on, #on?, #powerInterrupt, #reset, #softShutdown, #soft_shutdown

Methods inherited from BaseCommand

#find_fix, #makecommand, #max_retry_count, #setpass, #validate_status

Methods inherited from BaseCommand

#dump_command, #find_fix, #locate_command, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status

Constructor Details

#initialize(opts = ObservableHash.new) ⇒ Power

Returns a new instance of Power.



7
8
9
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 7

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



12
13
14
15
16
17
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 12

def command(opt)
  @options[opt] = false
  runcmd
  @options.delete_notify(opt)
  @result
end

#power_interruptObject



19
20
21
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 19

def power_interrupt
  command("pulse")
end

#statusObject

Get the power status of the system, will show either on or off



24
25
26
27
# File 'lib/rubyipmi/freeipmi/commands/power.rb', line 24

def status
  value = command("stat")
  @result.split(":").last.chomp.strip if value
end