Class: Rubyipmi::Ipmitool::Power

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

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

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/ipmitool/commands/power.rb', line 7

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



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

def command(opt)
  @options["cmdargs"] = "power #{opt}"
  value = runcmd
  @options.delete_notify("cmdargs")
  value
end

#power_interruptObject



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

def power_interrupt
  command("diag")
end

#statusObject

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



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

def status
  value = command("status")
  @result.match(/(off|on)/).to_s if value
end