Class: Rubyipmi::Ipmitool::Chassis

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/ipmitool/commands/chassis.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) ⇒ Chassis

Returns a new instance of Chassis.



5
6
7
8
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 5

def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)

end

Instance Method Details

#bootbios(reboot = false, persistent = false) ⇒ Object

boot into bios setup with option to reboot



83
84
85
86
87
88
89
90
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 83

def bootbios(reboot=false,persistent=false)
  bootstatus = config.bootbios(persistent)
  # Only reboot if setting the boot flag was successful
  if reboot and bootstatus
    power.cycle
  end
  return bootstatus
end

#bootcdrom(reboot = false, persistent = false) ⇒ Object

set boot device to cdrom with option to reboot



73
74
75
76
77
78
79
80
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 73

def bootcdrom(reboot=false,persistent=false)
  bootstatus = config.bootcdrom(persistent)
  # Only reboot if setting the boot flag was successful
  if reboot and bootstatus
    power.cycle
  end
  return bootstatus
end

#bootdevice(device, reboot = false, persistent = false) ⇒ Object

set boot device from given boot device



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 39

def bootdevice(device, reboot=false,persistent=false)
  if config.bootdevices.include?(device)
    bootstatus = config.bootdevice(device, persistent)
    if reboot and status
      power.cycle
    end

  else
    raise "Device with name: #{device} is not a valid boot device for host #{options["hostname"]}"
  end
  return bootstatus
end

#bootdisk(reboot = false, persistent = false) ⇒ Object

set boot device to disk with option to reboot



63
64
65
66
67
68
69
70
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 63

def bootdisk(reboot=false,persistent=false)
  bootstatus = config.bootdisk(persistent)
  # Only reboot if setting the boot flag was successful
  if reboot and bootstatus
    power.cycle
  end
  return bootstatus
end

#bootpxe(reboot = false, persistent = false) ⇒ Object

set boot device to pxe with option to reboot



53
54
55
56
57
58
59
60
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 53

def bootpxe(reboot=false,persistent=false)
  bootstatus = config.bootpxe(persistent)
  # Only reboot if setting the boot flag was successful
  if reboot and bootstatus
    power.cycle
  end
  return bootstatus
end

#configObject

Access to the config command created on the fly



34
35
36
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 34

def config
  @config ||= Rubyipmi::Ipmitool::ChassisConfig.new(@options)
end

#identify(status = false, delay = 0) ⇒ Object

Turn the led light on / off or with a delay status means to enable or disable the blinking



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 12

def identify(status=false, delay=0)
  if status
    if not delay.between?(1,255)
      options["cmdargs"] = "chassis identify 255"
    else
      options["cmdargs"] = "chassis identify #{delay}"
    end
  else
    options["cmdargs"] = "chassis identify 0"
  end
  # Run the command
  value = runcmd
  options.delete_notify("cmdargs")
  return value
end

#identifystatusObject

A currently unsupported method to retrieve the led status



100
101
102
103
104
105
106
107
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 100

def identifystatus
  options["cmdargs"] = "chassis identify status"
  value = runcmd
  options.delete_notify("cmdargs")
  if value
    @result.chomp.split(":").last.strip
  end
end

#powerObject

Access to the power command created on the fly



29
30
31
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 29

def power
  @power ||= Rubyipmi::Ipmitool::Power.new(@options)
end

#statusObject



92
93
94
95
96
97
# File 'lib/rubyipmi/ipmitool/commands/chassis.rb', line 92

def status
   options["cmdargs"] = "chassis status"
   value = runcmd
   options.delete_notify("cmdargs")
   return { :result => @result, :value => value }
end