Class: Rubyipmi::Ipmitool::Power

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

#cycleObject

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

#offObject

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

Returns:

  • (Boolean)


75
76
77
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 75

def off?
  status == "off"
end

#onObject

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

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 69

def on?
  status == "on"

end

#powerInterruptObject



56
57
58
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 56

def powerInterrupt
  command("diag")
end

#resetObject

Perform a power reset on the system



47
48
49
# File 'lib/rubyipmi/ipmitool/commands/power.rb', line 47

def reset
  command("reset")
end

#softShutdownObject

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

#statusObject

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