rubyipmi 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.document +5 -0
- data/.gitignore +50 -0
- data/.rspec +1 -0
- data/.rubocop.yml +66 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -3
- data/README.md +9 -3
- data/RELEASE_NOTES.md +33 -0
- data/Rakefile +15 -42
- data/lib/rubyipmi/commands/basecommand.rb +17 -23
- data/lib/rubyipmi/commands/mixins/power_mixin.rb +50 -0
- data/lib/rubyipmi/commands/mixins/sensors_mixin.rb +54 -0
- data/lib/rubyipmi/freeipmi/commands/basecommand.rb +26 -35
- data/lib/rubyipmi/freeipmi/commands/bmc.rb +4 -7
- data/lib/rubyipmi/freeipmi/commands/bmcconfig.rb +7 -17
- data/lib/rubyipmi/freeipmi/commands/bmcdevice.rb +2 -9
- data/lib/rubyipmi/freeipmi/commands/bmcinfo.rb +4 -10
- data/lib/rubyipmi/freeipmi/commands/chassis.rb +27 -45
- data/lib/rubyipmi/freeipmi/commands/chassisconfig.rb +23 -38
- data/lib/rubyipmi/freeipmi/commands/fru.rb +23 -42
- data/lib/rubyipmi/freeipmi/commands/lan.rb +4 -6
- data/lib/rubyipmi/freeipmi/commands/power.rb +8 -51
- data/lib/rubyipmi/freeipmi/commands/sensors.rb +10 -67
- data/lib/rubyipmi/freeipmi/connection.rb +14 -17
- data/lib/rubyipmi/freeipmi/errorcodes.rb +11 -17
- data/lib/rubyipmi/ipmitool/commands/basecommand.rb +12 -16
- data/lib/rubyipmi/ipmitool/commands/bmc.rb +13 -22
- data/lib/rubyipmi/ipmitool/commands/chassis.rb +26 -44
- data/lib/rubyipmi/ipmitool/commands/chassisconfig.rb +11 -21
- data/lib/rubyipmi/ipmitool/commands/fru.rb +35 -48
- data/lib/rubyipmi/ipmitool/commands/lan.rb +25 -28
- data/lib/rubyipmi/ipmitool/commands/power.rb +7 -58
- data/lib/rubyipmi/ipmitool/commands/sensors.rb +10 -68
- data/lib/rubyipmi/ipmitool/connection.rb +10 -19
- data/lib/rubyipmi/ipmitool/errorcodes.rb +11 -45
- data/lib/rubyipmi/observablehash.rb +1 -2
- data/lib/rubyipmi/version.rb +5 -0
- data/lib/rubyipmi.rb +23 -28
- data/rubyipmi.gemspec +17 -128
- metadata +18 -101
- data/spec/Vagrantfile +0 -45
- data/spec/fixtures/freeipmi/bmc_config.txt +0 -317
- data/spec/fixtures/freeipmi/bmc_config_lan_conf.txt +0 -19
- data/spec/fixtures/freeipmi/bmc_info.txt +0 -32
- data/spec/fixtures/freeipmi/errors.txt +0 -3
- data/spec/fixtures/freeipmi/fru.txt +0 -13
- data/spec/fixtures/freeipmi/sensors.txt +0 -29
- data/spec/fixtures/ipmitool/bmc_info.txt +0 -20
- data/spec/fixtures/ipmitool/errors.txt +0 -10
- data/spec/fixtures/ipmitool/fru.txt +0 -96
- data/spec/fixtures/ipmitool/lan.txt +0 -17
- data/spec/fixtures/ipmitool/sensors.txt +0 -105
- data/spec/integration/bmc_spec.rb +0 -48
- data/spec/integration/chassis_config_spec.rb +0 -38
- data/spec/integration/chassis_spec.rb +0 -26
- data/spec/integration/connection_spec.rb +0 -45
- data/spec/integration/fru_spec.rb +0 -38
- data/spec/integration/lan_spec.rb +0 -50
- data/spec/integration/power_spec.rb +0 -40
- data/spec/integration/rubyipmi_spec.rb +0 -114
- data/spec/integration/sensor_spec.rb +0 -43
- data/spec/manifests/default.pp +0 -50
- data/spec/puppetmodules/archive/LICENSE-2.0.txt +0 -202
- data/spec/puppetmodules/archive/Modulefile +0 -8
- data/spec/puppetmodules/archive/README.md +0 -40
- data/spec/puppetmodules/archive/manifests/download.pp +0 -157
- data/spec/puppetmodules/archive/manifests/extract.pp +0 -81
- data/spec/puppetmodules/archive/manifests/init.pp +0 -70
- data/spec/puppetmodules/archive/manifests/tar-gz.pp +0 -7
- data/spec/puppetmodules/archive/manifests/zip.pp +0 -7
- data/spec/puppetmodules/archive/metadata.json +0 -26
- data/spec/spec_helper.rb +0 -47
- data/spec/unit/freeipmi/bmc-info_spec.rb +0 -38
- data/spec/unit/freeipmi/bmc_spec.rb +0 -43
- data/spec/unit/freeipmi/connection_spec.rb +0 -121
- data/spec/unit/freeipmi/errorcodes_spec.rb +0 -28
- data/spec/unit/freeipmi/fru_spec.rb +0 -76
- data/spec/unit/freeipmi/lan_spec.rb +0 -0
- data/spec/unit/freeipmi/sensors_spec.rb +0 -85
- data/spec/unit/ipmitool/bmc_spec.rb +0 -77
- data/spec/unit/ipmitool/connection_spec.rb +0 -122
- data/spec/unit/ipmitool/errorcodes_spec.rb +0 -35
- data/spec/unit/ipmitool/fru_spec.rb +0 -77
- data/spec/unit/ipmitool/lan_spec.rb +0 -94
- data/spec/unit/ipmitool/sensors_spec.rb +0 -96
- data/spec/unit/rubyipmi_spec.rb +0 -50
- data/spec/vagrant +0 -27
- data/spec/vagrant.pub +0 -1
@@ -1,85 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'rubyipmi/commands/mixins/sensors_mixin'
|
2
2
|
|
3
|
+
module Rubyipmi::Freeipmi
|
3
4
|
class Sensors < Rubyipmi::Freeipmi::BaseCommand
|
5
|
+
include Rubyipmi::SensorsMixin
|
4
6
|
|
5
7
|
def initialize(opts = ObservableHash.new)
|
6
8
|
super("ipmi-sensors", opts)
|
7
9
|
end
|
8
10
|
|
9
|
-
def refresh
|
10
|
-
@sensors = nil
|
11
|
-
list
|
12
|
-
end
|
13
|
-
|
14
|
-
def list
|
15
|
-
@sensors ||= parse(getsensors)
|
16
|
-
end
|
17
|
-
|
18
|
-
def count
|
19
|
-
list.count
|
20
|
-
end
|
21
|
-
|
22
|
-
def names
|
23
|
-
list.keys
|
24
|
-
end
|
25
|
-
|
26
|
-
# returns a hash of fan sensors where the key is fan name and value is the sensor
|
27
|
-
def fanlist(refreshdata=false)
|
28
|
-
refresh if refreshdata
|
29
|
-
flist = {}
|
30
|
-
list.each do | name,sensor |
|
31
|
-
if name =~ /.*fan.*/
|
32
|
-
flist[name] = sensor
|
33
|
-
end
|
34
|
-
end
|
35
|
-
return flist
|
36
|
-
end
|
37
|
-
|
38
|
-
# returns a hash of sensors where each key is the name of the sensor and the value is the sensor
|
39
|
-
def templist(refreshdata=false)
|
40
|
-
refresh if refreshdata
|
41
|
-
tlist = {}
|
42
|
-
list.each do | name , sensor |
|
43
|
-
if sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/
|
44
|
-
tlist[name] = sensor
|
45
|
-
end
|
46
|
-
end
|
47
|
-
return tlist
|
48
|
-
end
|
49
|
-
|
50
11
|
def getsensors
|
51
12
|
@options["no-header-output"] = false
|
52
13
|
@options["output-sensor-state"] = false
|
53
14
|
@options["entity-sensor-names"] = false
|
54
|
-
|
15
|
+
runcmd
|
55
16
|
@options.delete_notify('no-header-output')
|
56
17
|
@options.delete_notify('output-sensor-state')
|
57
18
|
@options.delete_notify('entity-sensor-names')
|
58
19
|
@result
|
59
20
|
end
|
60
21
|
|
61
|
-
|
62
|
-
|
63
|
-
def method_missing(method, *args, &block)
|
64
|
-
if not list.has_key?(method.to_s)
|
65
|
-
raise NoMethodError
|
66
|
-
else
|
67
|
-
list[method.to_s]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def parse(data)
|
72
|
-
sensorlist = {}
|
73
|
-
if ! data.nil?
|
74
|
-
data.lines.each do | line|
|
75
|
-
# skip the header
|
76
|
-
sensor = Sensor.new(line)
|
77
|
-
sensorlist[sensor[:name]] = sensor
|
78
|
-
end
|
79
|
-
end
|
80
|
-
return sensorlist
|
22
|
+
def sensor_class
|
23
|
+
Sensor
|
81
24
|
end
|
82
|
-
|
83
25
|
end
|
84
26
|
|
85
27
|
class Sensor < Hash
|
@@ -89,6 +31,7 @@ module Rubyipmi::Freeipmi
|
|
89
31
|
end
|
90
32
|
|
91
33
|
private
|
34
|
+
|
92
35
|
def normalize(text)
|
93
36
|
text.gsub(/\ /, '_').gsub(/\./, '').downcase
|
94
37
|
end
|
@@ -97,16 +40,16 @@ module Rubyipmi::Freeipmi
|
|
97
40
|
# Note: not all fields will exist on every server
|
98
41
|
def parse(line)
|
99
42
|
fields = [:id_num, :name, :value, :unit, :status, :type, :state, :lower_nonrec,
|
100
|
-
:lower_crit
|
43
|
+
:lower_crit, :lower_noncrit, :upper_crit, :upper_nonrec, :asserts_enabled, :deasserts_enabled]
|
101
44
|
data = line.split(/\|/)
|
102
45
|
# should we ever encounter a field not in the fields list, just use a counter based fieldname so we just
|
103
46
|
# use field1, field2, field3, ...
|
104
47
|
i = 0
|
105
|
-
data.each do |
|
48
|
+
data.each do |value|
|
106
49
|
field ||= fields.shift || "field#{i}"
|
107
50
|
self[field] = value.strip
|
108
51
|
i = i.next
|
109
52
|
end
|
110
53
|
end
|
111
54
|
end
|
112
|
-
end
|
55
|
+
end
|
@@ -6,11 +6,18 @@ require 'rubyipmi/freeipmi/commands/basecommand'
|
|
6
6
|
Dir[File.dirname(__FILE__) + '/commands/*.rb'].each do |file|
|
7
7
|
require file
|
8
8
|
end
|
9
|
+
|
9
10
|
module Rubyipmi
|
10
11
|
module Freeipmi
|
11
12
|
class Connection
|
12
13
|
attr_accessor :options
|
13
14
|
|
15
|
+
DRIVERS_MAP = {
|
16
|
+
'lan15' => 'LAN',
|
17
|
+
'lan20' => 'LAN_2_0',
|
18
|
+
'open' => 'OPENIPMI'
|
19
|
+
}
|
20
|
+
|
14
21
|
def initialize(user, pass, host, opts)
|
15
22
|
@options = Rubyipmi::ObservableHash.new
|
16
23
|
raise("Must provide a host to connect to") unless host
|
@@ -19,29 +26,19 @@ module Rubyipmi
|
|
19
26
|
# So they are not required
|
20
27
|
@options["username"] = user if user
|
21
28
|
@options["password"] = pass if pass
|
22
|
-
if opts.
|
23
|
-
@options["privilege-level"] = opts[:privilege]
|
29
|
+
if opts.key?(:privilege)
|
30
|
+
@options["privilege-level"] = opts[:privilege] # privilege type
|
24
31
|
end
|
25
32
|
# Note: rubyipmi should auto detect which driver to use so its unnecessary to specify the driver unless
|
26
33
|
# the user really wants to
|
27
|
-
@options['driver-type'] =
|
34
|
+
@options['driver-type'] = DRIVERS_MAP[opts[:driver]] unless DRIVERS_MAP[opts[:driver]].nil?
|
28
35
|
end
|
29
36
|
|
30
37
|
# test the connection to ensure we can at least make a single call
|
31
38
|
def connection_works?
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def drivers_map
|
40
|
-
{
|
41
|
-
'lan15' => 'LAN',
|
42
|
-
'lan20' => 'LAN_2_0',
|
43
|
-
'open' => 'OPENIPMI'
|
44
|
-
}
|
39
|
+
! (bmc.info.nil? || bmc.info.empty?)
|
40
|
+
rescue
|
41
|
+
false
|
45
42
|
end
|
46
43
|
|
47
44
|
def provider
|
@@ -75,4 +72,4 @@ module Rubyipmi
|
|
75
72
|
end
|
76
73
|
end
|
77
74
|
end
|
78
|
-
end
|
75
|
+
end
|
@@ -1,37 +1,31 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class ErrorCodes
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
"authentication type unavailable for attempted privilege level\n" => {"driver-type" => "LAN_2_0"},
|
3
|
+
CODES = {
|
4
|
+
"authentication type unavailable for attempted privilege level" => {"driver-type" => "LAN_2_0"},
|
5
|
+
"authentication type unavailable for attempted privilege level\n" => {"driver-type" => "LAN_2_0"}
|
8
6
|
}
|
9
7
|
|
10
8
|
def self.length
|
11
|
-
|
9
|
+
CODES.length
|
12
10
|
end
|
13
11
|
|
14
12
|
def self.code
|
15
|
-
|
13
|
+
CODES
|
16
14
|
end
|
17
15
|
|
18
16
|
def self.search(code)
|
19
17
|
# example error code:
|
20
18
|
# "/usr/local/sbin/bmc-info: authentication type unavailable for attempted privilege level\n"
|
21
|
-
code.chomp!
|
22
|
-
code = code.split(':').last.strip
|
23
|
-
fix =
|
19
|
+
code.chomp! # clean up newline
|
20
|
+
code = code.split(':').last.strip # clean up left hand side and strip white space from sides
|
21
|
+
fix = CODES.fetch(code, nil)
|
24
22
|
if fix.nil?
|
25
|
-
|
26
|
-
if code =~ /.*#{error}.*/i
|
27
|
-
fix = result
|
28
|
-
end
|
23
|
+
CODES.each do |error, result|
|
24
|
+
fix = result if code =~ /.*#{error}.*/i
|
29
25
|
end
|
30
26
|
end
|
31
27
|
raise "No Fix found" if fix.nil?
|
32
|
-
|
28
|
+
fix
|
33
29
|
end
|
34
|
-
|
35
30
|
end
|
36
|
-
|
37
31
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'rubyipmi/ipmitool/errorcodes'
|
2
2
|
|
3
3
|
module Rubyipmi::Ipmitool
|
4
|
-
|
5
4
|
class BaseCommand < Rubyipmi::BaseCommand
|
6
|
-
|
7
5
|
def setpass
|
8
6
|
super
|
9
7
|
@options["f"] = @passfile.path
|
10
|
-
@passfile.write "#{@options[
|
8
|
+
@passfile.write "#{@options['P']}"
|
11
9
|
@passfile.rewind
|
12
10
|
@passfile.close
|
13
11
|
end
|
@@ -19,7 +17,7 @@ module Rubyipmi::Ipmitool
|
|
19
17
|
def makecommand
|
20
18
|
args = ''
|
21
19
|
# need to format the options to ipmitool format
|
22
|
-
@options.each do
|
20
|
+
@options.each do |k, v|
|
23
21
|
# must remove from command line as its handled via conf file
|
24
22
|
next if k == "P"
|
25
23
|
next if k == "cmdargs"
|
@@ -27,26 +25,24 @@ module Rubyipmi::Ipmitool
|
|
27
25
|
end
|
28
26
|
|
29
27
|
# since ipmitool requires commands to be in specific order
|
30
|
-
|
31
28
|
args << ' ' + options.fetch('cmdargs', '')
|
32
29
|
|
33
|
-
|
30
|
+
"#{cmd} #{args.lstrip}"
|
34
31
|
end
|
35
32
|
|
36
33
|
# The findfix method acts like a recursive method and applies fixes defined in the errorcodes
|
37
34
|
# If a fix is found it is applied to the options hash, and then the last run command is retried
|
38
35
|
# until all the fixes are exhausted or a error not defined in the errorcodes is found
|
39
36
|
def find_fix(result)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
37
|
+
return unless result
|
38
|
+
# The errorcode code hash contains the fix
|
39
|
+
begin
|
40
|
+
fix = ErrorCodes.search(result)
|
41
|
+
@options.merge_notify!(fix)
|
42
|
+
|
43
|
+
rescue
|
44
|
+
raise "Could not find fix for error code: \n#{result}"
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
52
|
-
end
|
48
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Rubyipmi::Ipmitool
|
2
|
-
|
3
2
|
class Bmc < Rubyipmi::Ipmitool::BaseCommand
|
4
|
-
|
5
3
|
attr_accessor :config
|
6
4
|
|
7
5
|
def initialize(opts = ObservableHash.new)
|
@@ -23,38 +21,33 @@ module Rubyipmi::Ipmitool
|
|
23
21
|
|
24
22
|
def version
|
25
23
|
@options['V'] = nil
|
26
|
-
|
24
|
+
runcmd
|
27
25
|
@options.delete_notify('V')
|
28
26
|
@result.slice(/\d\.\d.\d/)
|
29
27
|
end
|
30
28
|
|
31
29
|
# reset the bmc device, useful for troubleshooting
|
32
|
-
def reset(type='cold')
|
30
|
+
def reset(type = 'cold')
|
33
31
|
if ['cold', 'warm'].include?(type)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
@options["cmdargs"] = "bmc reset #{type}"
|
33
|
+
value = runcmd
|
34
|
+
@options.delete_notify("cmdargs")
|
35
|
+
return value
|
38
36
|
else
|
39
37
|
logger.error("reset type: #{type} is not a valid choice, use warm or cold") if logger
|
40
38
|
raise "reset type: #{type} is not a valid choice, use warm or cold"
|
41
39
|
end
|
42
|
-
|
43
40
|
end
|
44
41
|
|
45
42
|
def guid
|
46
43
|
@options["cmdargs"] = "bmc guid"
|
47
|
-
value = runcmd
|
44
|
+
value = runcmd
|
48
45
|
@options.delete_notify("cmdargs")
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
line.split(":").last.strip
|
54
|
-
end
|
55
|
-
}
|
46
|
+
return unless value
|
47
|
+
@result.lines.each do |line|
|
48
|
+
line.chomp
|
49
|
+
line.split(":").last.strip if line =~ /GUID/
|
56
50
|
end
|
57
|
-
|
58
51
|
end
|
59
52
|
|
60
53
|
# This function will get the bmcinfo and return a hash of each item in the info
|
@@ -63,7 +56,7 @@ module Rubyipmi::Ipmitool
|
|
63
56
|
status = runcmd
|
64
57
|
@options.delete_notify("cmdargs")
|
65
58
|
subkey = nil
|
66
|
-
if
|
59
|
+
if !status
|
67
60
|
raise @result
|
68
61
|
else
|
69
62
|
@result.lines.each do |line|
|
@@ -75,7 +68,7 @@ module Rubyipmi::Ipmitool
|
|
75
68
|
if value.empty?
|
76
69
|
subkey = key
|
77
70
|
@bmcinfo[subkey] = []
|
78
|
-
elsif key == value
|
71
|
+
elsif key == value && subkey
|
79
72
|
# subvalue found
|
80
73
|
@bmcinfo[subkey] << value
|
81
74
|
else
|
@@ -87,7 +80,5 @@ module Rubyipmi::Ipmitool
|
|
87
80
|
return @bmcinfo
|
88
81
|
end
|
89
82
|
end
|
90
|
-
|
91
|
-
|
92
83
|
end
|
93
84
|
end
|
@@ -1,17 +1,14 @@
|
|
1
1
|
module Rubyipmi::Ipmitool
|
2
|
-
|
3
2
|
class Chassis < Rubyipmi::Ipmitool::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("ipmitool", opts)
|
7
|
-
|
8
5
|
end
|
9
6
|
|
10
7
|
# Turn the led light on / off or with a delay
|
11
8
|
# status means to enable or disable the blinking
|
12
|
-
def identify(status=false, delay=0)
|
9
|
+
def identify(status = false, delay = 0)
|
13
10
|
if status
|
14
|
-
if
|
11
|
+
if !delay.between?(1, 255)
|
15
12
|
options["cmdargs"] = "chassis identify 255"
|
16
13
|
else
|
17
14
|
options["cmdargs"] = "chassis identify #{delay}"
|
@@ -22,7 +19,7 @@ module Rubyipmi::Ipmitool
|
|
22
19
|
# Run the command
|
23
20
|
value = runcmd
|
24
21
|
options.delete_notify("cmdargs")
|
25
|
-
|
22
|
+
value
|
26
23
|
end
|
27
24
|
|
28
25
|
# Access to the power command created on the fly
|
@@ -36,65 +33,54 @@ module Rubyipmi::Ipmitool
|
|
36
33
|
end
|
37
34
|
|
38
35
|
# set boot device from given boot device
|
39
|
-
def bootdevice(device, reboot=false,persistent=false)
|
36
|
+
def bootdevice(device, reboot = false, persistent = false)
|
40
37
|
if config.bootdevices.include?(device)
|
41
38
|
bootstatus = config.bootdevice(device, persistent)
|
42
|
-
if reboot
|
43
|
-
power.cycle
|
44
|
-
end
|
45
|
-
|
39
|
+
power.cycle if reboot && status
|
46
40
|
else
|
47
|
-
logger.debug("Device with name: #{device} is not a valid boot device for host #{options[
|
48
|
-
raise "Device with name: #{device} is not a valid boot device for host #{options[
|
41
|
+
logger.debug("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") if logger
|
42
|
+
raise "Device with name: #{device} is not a valid boot device for host #{options['hostname']}"
|
49
43
|
end
|
50
|
-
|
44
|
+
bootstatus
|
51
45
|
end
|
52
46
|
|
53
47
|
# set boot device to pxe with option to reboot
|
54
|
-
def bootpxe(reboot=false,persistent=false)
|
48
|
+
def bootpxe(reboot = false, persistent = false)
|
55
49
|
bootstatus = config.bootpxe(persistent)
|
56
50
|
# Only reboot if setting the boot flag was successful
|
57
|
-
if reboot
|
58
|
-
|
59
|
-
end
|
60
|
-
return bootstatus
|
51
|
+
power.cycle if reboot && bootstatus
|
52
|
+
bootstatus
|
61
53
|
end
|
62
54
|
|
63
55
|
# set boot device to disk with option to reboot
|
64
|
-
def bootdisk(reboot=false,persistent=false)
|
56
|
+
def bootdisk(reboot = false, persistent = false)
|
65
57
|
bootstatus = config.bootdisk(persistent)
|
66
58
|
# Only reboot if setting the boot flag was successful
|
67
|
-
if reboot
|
68
|
-
|
69
|
-
end
|
70
|
-
return bootstatus
|
59
|
+
power.cycle if reboot && bootstatus
|
60
|
+
bootstatus
|
71
61
|
end
|
72
62
|
|
73
63
|
# set boot device to cdrom with option to reboot
|
74
|
-
def bootcdrom(reboot=false,persistent=false)
|
64
|
+
def bootcdrom(reboot = false, persistent = false)
|
75
65
|
bootstatus = config.bootcdrom(persistent)
|
76
66
|
# Only reboot if setting the boot flag was successful
|
77
|
-
if reboot
|
78
|
-
|
79
|
-
end
|
80
|
-
return bootstatus
|
67
|
+
power.cycle if reboot && bootstatus
|
68
|
+
bootstatus
|
81
69
|
end
|
82
70
|
|
83
71
|
# boot into bios setup with option to reboot
|
84
|
-
def bootbios(reboot=false,persistent=false)
|
72
|
+
def bootbios(reboot = false, persistent = false)
|
85
73
|
bootstatus = config.bootbios(persistent)
|
86
74
|
# Only reboot if setting the boot flag was successful
|
87
|
-
if reboot
|
88
|
-
|
89
|
-
end
|
90
|
-
return bootstatus
|
75
|
+
power.cycle if reboot && bootstatus
|
76
|
+
bootstatus
|
91
77
|
end
|
92
78
|
|
93
79
|
def status
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
80
|
+
options["cmdargs"] = "chassis status"
|
81
|
+
value = runcmd
|
82
|
+
options.delete_notify("cmdargs")
|
83
|
+
{:result => @result, :value => value}
|
98
84
|
end
|
99
85
|
|
100
86
|
# A currently unsupported method to retrieve the led status
|
@@ -102,11 +88,7 @@ module Rubyipmi::Ipmitool
|
|
102
88
|
options["cmdargs"] = "chassis identify status"
|
103
89
|
value = runcmd
|
104
90
|
options.delete_notify("cmdargs")
|
105
|
-
if value
|
106
|
-
@result.chomp.split(":").last.strip
|
107
|
-
end
|
91
|
+
@result.chomp.split(":").last.strip if value
|
108
92
|
end
|
109
|
-
|
110
|
-
|
111
93
|
end
|
112
|
-
end
|
94
|
+
end
|
@@ -1,20 +1,11 @@
|
|
1
1
|
module Rubyipmi::Ipmitool
|
2
|
-
|
3
2
|
class ChassisConfig < Rubyipmi::Ipmitool::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("ipmitool", opts)
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
# Get the current boot device
|
11
|
-
def bootdevice
|
12
|
-
# Not available with ipmitool
|
13
|
-
false
|
14
5
|
end
|
15
6
|
|
16
7
|
# Set the boot device
|
17
|
-
def bootdevice(device, persistent=false)
|
8
|
+
def bootdevice(device, persistent = false)
|
18
9
|
if persistent
|
19
10
|
@options["cmdargs"] = "chassis bootdev #{device}"
|
20
11
|
else
|
@@ -22,7 +13,7 @@ module Rubyipmi::Ipmitool
|
|
22
13
|
end
|
23
14
|
value = runcmd
|
24
15
|
@options.delete_notify("cmdargs")
|
25
|
-
|
16
|
+
value
|
26
17
|
end
|
27
18
|
|
28
19
|
# Get list of available boot devices
|
@@ -33,24 +24,23 @@ module Rubyipmi::Ipmitool
|
|
33
24
|
end
|
34
25
|
|
35
26
|
# shortcut to set boot device to pxe
|
36
|
-
def bootpxe(persistent=true)
|
37
|
-
bootdevice("pxe",persistent)
|
27
|
+
def bootpxe(persistent = true)
|
28
|
+
bootdevice("pxe", persistent)
|
38
29
|
end
|
39
30
|
|
40
31
|
# shortcut to set boot device to disk
|
41
|
-
def bootdisk(persistent=true)
|
42
|
-
bootdevice("disk",persistent)
|
32
|
+
def bootdisk(persistent = true)
|
33
|
+
bootdevice("disk", persistent)
|
43
34
|
end
|
44
35
|
|
45
36
|
# shortcut to set boot device to cdrom
|
46
|
-
def bootcdrom(persistent=true)
|
47
|
-
bootdevice("cdrom",persistent)
|
37
|
+
def bootcdrom(persistent = true)
|
38
|
+
bootdevice("cdrom", persistent)
|
48
39
|
end
|
49
40
|
|
50
41
|
# shortcut to boot into bios setup
|
51
|
-
def bootbios(persistent=true)
|
52
|
-
bootdevice("bios",persistent)
|
42
|
+
def bootbios(persistent = true)
|
43
|
+
bootdevice("bios", persistent)
|
53
44
|
end
|
54
|
-
|
55
45
|
end
|
56
|
-
end
|
46
|
+
end
|