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,14 +1,11 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class BmcConfig < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("bmc-config", opts)
|
7
5
|
@sections = []
|
8
|
-
|
9
6
|
end
|
10
7
|
|
11
|
-
def verbose(on=false)
|
8
|
+
def verbose(on = false)
|
12
9
|
if on
|
13
10
|
@options['verbose'] = false
|
14
11
|
else
|
@@ -19,32 +16,29 @@ module Rubyipmi::Freeipmi
|
|
19
16
|
def section(section)
|
20
17
|
@options["checkout"] = false
|
21
18
|
@options["section"] = section
|
22
|
-
|
19
|
+
runcmd
|
23
20
|
@options.delete_notify("checkout")
|
24
21
|
@options.delete_notify("section")
|
25
|
-
|
22
|
+
@result
|
26
23
|
end
|
27
24
|
|
28
25
|
def setsection(section, key, value)
|
29
26
|
keypair = "#{section}:#{key}=#{value}"
|
30
27
|
@options["commit"] = false
|
31
|
-
|
28
|
+
unless keypair.empty?
|
32
29
|
@options["key-pair"] = keypair
|
33
30
|
value = runcmd
|
34
31
|
@options.delete_notify("commit")
|
35
32
|
@options.delete_notify("key-pair")
|
36
33
|
return value
|
37
34
|
end
|
38
|
-
|
35
|
+
false
|
39
36
|
end
|
40
37
|
|
41
|
-
|
42
38
|
# returns the entire bmc-config configuration, can take a while to execute
|
43
39
|
def configuration
|
44
|
-
require 'pry'
|
45
|
-
binding.pry
|
46
40
|
@options["checkout"] = false
|
47
|
-
|
41
|
+
runcmd
|
48
42
|
@options.delete_notify("checkout")
|
49
43
|
@result
|
50
44
|
end
|
@@ -55,13 +49,9 @@ module Rubyipmi::Freeipmi
|
|
55
49
|
@options["listsections"] = false
|
56
50
|
value = runcmd
|
57
51
|
@options.delete_notify("listsections")
|
58
|
-
if value
|
59
|
-
@sections = @result.split(/\n/)
|
60
|
-
end
|
52
|
+
@sections = @result.split(/\n/) if value
|
61
53
|
end
|
62
54
|
@sections
|
63
55
|
end
|
64
|
-
|
65
|
-
|
66
56
|
end
|
67
57
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class BmcDevice < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("bmc-device", opts)
|
7
5
|
end
|
@@ -11,11 +9,11 @@ module Rubyipmi::Freeipmi
|
|
11
9
|
@options[opt] = false
|
12
10
|
value = runcmd
|
13
11
|
@options.delete_notify(opt)
|
14
|
-
|
12
|
+
value
|
15
13
|
end
|
16
14
|
|
17
15
|
# reset the bmc device, useful for debugging and troubleshooting
|
18
|
-
def reset(type='cold')
|
16
|
+
def reset(type = 'cold')
|
19
17
|
if ['cold', 'warm'].include?(type)
|
20
18
|
key = "#{type}-reset"
|
21
19
|
command(key)
|
@@ -24,10 +22,5 @@ module Rubyipmi::Freeipmi
|
|
24
22
|
raise "reset type: #{type} is not a valid choice, use warm or cold"
|
25
23
|
end
|
26
24
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
25
|
end
|
31
|
-
|
32
|
-
|
33
26
|
end
|
@@ -1,29 +1,25 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class BmcInfo < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("bmc-info", opts)
|
7
|
-
|
8
5
|
end
|
9
6
|
|
10
7
|
def guid
|
11
8
|
options["get-device-guid"] = false
|
12
9
|
status = runcmd
|
13
10
|
options.delete_notify("get-device-guid")
|
14
|
-
if
|
11
|
+
if !status
|
15
12
|
raise @result
|
16
13
|
else
|
17
14
|
@result.chomp.strip
|
18
15
|
end
|
19
|
-
|
20
16
|
end
|
21
17
|
|
22
18
|
def retrieve
|
23
19
|
bmcinfo = {}
|
24
20
|
status = runcmd
|
25
21
|
subkey = nil
|
26
|
-
if
|
22
|
+
if !status
|
27
23
|
raise @result
|
28
24
|
else
|
29
25
|
@result.lines.each do |line|
|
@@ -32,10 +28,10 @@ module Rubyipmi::Freeipmi
|
|
32
28
|
key = item.first.strip
|
33
29
|
value = item.last.strip
|
34
30
|
# if the following condition is met we have subvalues
|
35
|
-
if key == value
|
31
|
+
if key == value && !subkey
|
36
32
|
subkey = key
|
37
33
|
bmcinfo[subkey] = []
|
38
|
-
elsif key == value
|
34
|
+
elsif key == value && subkey
|
39
35
|
# subvalue found
|
40
36
|
bmcinfo[subkey] << value.gsub(/\[|\]/, "")
|
41
37
|
else
|
@@ -49,5 +45,3 @@ module Rubyipmi::Freeipmi
|
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
52
|
-
|
53
|
-
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class Chassis < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("ipmi-chassis", opts)
|
7
|
-
|
8
5
|
end
|
9
6
|
|
10
7
|
# Turn the led light on / off or with a delay
|
11
|
-
def identify(status=false, delay=0)
|
8
|
+
def identify(status = false, delay = 0)
|
12
9
|
if status
|
13
10
|
if delay <= 0
|
14
11
|
options["chassis-identify"] = "FORCE"
|
@@ -21,7 +18,7 @@ module Rubyipmi::Freeipmi
|
|
21
18
|
# Run the command
|
22
19
|
value = runcmd
|
23
20
|
options.delete_notify("chassis-identify")
|
24
|
-
|
21
|
+
value
|
25
22
|
end
|
26
23
|
|
27
24
|
# Access to the power command created on the fly
|
@@ -35,80 +32,67 @@ module Rubyipmi::Freeipmi
|
|
35
32
|
end
|
36
33
|
|
37
34
|
# set boot device from given boot device
|
38
|
-
def bootdevice(device, reboot=false, persistent=false)
|
35
|
+
def bootdevice(device, reboot = false, persistent = false)
|
39
36
|
if config.bootdevices.include?(device)
|
40
37
|
bootstatus = config.bootdevice(device, persistent)
|
41
|
-
if reboot
|
42
|
-
power.cycle
|
43
|
-
end
|
44
|
-
|
38
|
+
power.cycle if reboot && bootstatus
|
45
39
|
else
|
46
|
-
logger.error("Device with name: #{device} is not a valid boot device for host #{options[
|
47
|
-
raise "Device with name: #{device} is not a valid boot device for host #{options[
|
40
|
+
logger.error("Device with name: #{device} is not a valid boot device for host #{options['hostname']}") if logger
|
41
|
+
raise "Device with name: #{device} is not a valid boot device for host #{options['hostname']}"
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
51
45
|
# set boot device to pxe with option to reboot
|
52
|
-
def bootpxe(reboot=false,persistent=false)
|
46
|
+
def bootpxe(reboot = false, persistent = false)
|
53
47
|
bootstatus = config.bootpxe(persistent)
|
54
48
|
# Only reboot if setting the boot flag was successful
|
55
|
-
if reboot
|
56
|
-
power.cycle
|
57
|
-
end
|
49
|
+
power.cycle if reboot && bootstatus
|
58
50
|
end
|
59
51
|
|
60
52
|
# set boot device to disk with option to reboot
|
61
|
-
def bootdisk(reboot=false,persistent=false)
|
53
|
+
def bootdisk(reboot = false, persistent = false)
|
62
54
|
bootstatus = config.bootdisk(persistent)
|
63
55
|
# Only reboot if setting the boot flag was successful
|
64
|
-
if reboot
|
65
|
-
power.cycle
|
66
|
-
end
|
67
|
-
|
56
|
+
power.cycle if reboot && bootstatus
|
68
57
|
end
|
69
58
|
|
70
59
|
# set boot device to cdrom with option to reboot
|
71
|
-
def bootcdrom(reboot=false,persistent=false)
|
60
|
+
def bootcdrom(reboot = false, persistent = false)
|
72
61
|
bootstatus = config.bootcdrom(persistent)
|
73
62
|
# Only reboot if setting the boot flag was successful
|
74
|
-
if reboot
|
75
|
-
power.cycle
|
76
|
-
end
|
63
|
+
power.cycle if reboot && bootstatus
|
77
64
|
end
|
78
65
|
|
79
66
|
# boot into bios setup with option to reboot
|
80
|
-
def bootbios(reboot=false,persistent=false)
|
67
|
+
def bootbios(reboot = false, persistent = false)
|
81
68
|
bootstatus = config.bootbios(persistent)
|
82
69
|
# Only reboot if setting the boot flag was successful
|
83
|
-
if reboot
|
84
|
-
power.cycle
|
85
|
-
end
|
70
|
+
power.cycle if reboot && bootstatus
|
86
71
|
end
|
87
72
|
|
88
73
|
def status
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
74
|
+
options["get-status"] = false
|
75
|
+
value = runcmd
|
76
|
+
options.delete_notify("get-status")
|
77
|
+
if value
|
78
|
+
return parsestatus
|
79
|
+
else
|
80
|
+
return value
|
81
|
+
end
|
98
82
|
end
|
99
83
|
|
100
84
|
# A currently unsupported method to retrieve the led status
|
101
85
|
def identifystatus
|
102
|
-
# TODO implement this function
|
86
|
+
# TODO: implement this function
|
103
87
|
# parse out the identify status
|
104
|
-
|
88
|
+
# status.result
|
105
89
|
end
|
106
90
|
|
107
91
|
private
|
92
|
+
|
108
93
|
def parsestatus
|
109
94
|
statusresult = @result
|
110
95
|
statusvalues = {}
|
111
|
-
subkey = nil
|
112
96
|
statusresult.lines.each do |line|
|
113
97
|
# clean up the data from spaces
|
114
98
|
item = line.split(':')
|
@@ -116,9 +100,7 @@ module Rubyipmi::Freeipmi
|
|
116
100
|
value = item.last.strip
|
117
101
|
statusvalues[key] = value
|
118
102
|
end
|
119
|
-
|
103
|
+
statusvalues
|
120
104
|
end
|
121
|
-
|
122
|
-
|
123
105
|
end
|
124
|
-
end
|
106
|
+
end
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class ChassisConfig < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
def initialize(opts = ObservableHash.new)
|
6
4
|
super("ipmi-chassis-config", opts)
|
7
|
-
|
8
5
|
end
|
9
6
|
|
10
7
|
# This is the raw command to send a new configuration to the ipmi device
|
@@ -12,45 +9,33 @@ module Rubyipmi::Freeipmi
|
|
12
9
|
@options["commit"] = false
|
13
10
|
value = runcmd
|
14
11
|
@options.delete_notify("commit")
|
15
|
-
|
12
|
+
value
|
16
13
|
end
|
17
14
|
|
18
15
|
# This is the raw command to get the entire ipmi chassis configuration
|
19
16
|
# If you pass in a section you will get just the section
|
20
|
-
def checkout(section=nil)
|
17
|
+
def checkout(section = nil)
|
21
18
|
@options["checkout"] = false
|
22
|
-
if section
|
23
|
-
@options["section"] = section
|
24
|
-
end
|
19
|
+
@options["section"] = section if section
|
25
20
|
value = runcmd
|
26
21
|
@options.delete_notify("checkout")
|
27
|
-
if section
|
28
|
-
|
29
|
-
end
|
30
|
-
return value
|
31
|
-
end
|
32
|
-
|
33
|
-
def bootdevice
|
34
|
-
value = checkout("Chassis_Boot_Flags")
|
35
|
-
if value
|
36
|
-
# TODO parse result to return current boot device
|
37
|
-
#@result
|
38
|
-
end
|
22
|
+
@options.delete_notify("section") if section
|
23
|
+
value
|
39
24
|
end
|
40
25
|
|
41
26
|
def bootdevice(device, persistent)
|
42
|
-
|
27
|
+
set_boot_flag("Boot_Device", device, persistent)
|
43
28
|
end
|
44
29
|
|
45
30
|
def bootdevices
|
46
31
|
# freeipmi returns a list of supported devices
|
47
32
|
# However, for now we will just assume the following
|
48
33
|
["PXE", "HARD-DRIVE", "CD-DVD", "BIOS-SETUP"]
|
49
|
-
# TODO return array of possible boot devices
|
34
|
+
# TODO: return array of possible boot devices
|
50
35
|
end
|
51
36
|
|
52
37
|
def bootpersistent(value)
|
53
|
-
# TODO find out if we can specify multiple key-pair values
|
38
|
+
# TODO: find out if we can specify multiple key-pair values
|
54
39
|
if value == true
|
55
40
|
flag = "Chassis_Boot_Flags:Boot_Flags_Persistent=Yes"
|
56
41
|
else
|
@@ -59,40 +44,40 @@ module Rubyipmi::Freeipmi
|
|
59
44
|
@options["key-pair"] = "\"#{flag}\""
|
60
45
|
value = commit
|
61
46
|
@options.delete_notify("key-pair")
|
62
|
-
|
47
|
+
value
|
63
48
|
end
|
64
49
|
|
65
50
|
# shortcut to set boot device to pxe
|
66
|
-
def bootpxe(persistent=true)
|
67
|
-
bootdevice("PXE",persistent)
|
51
|
+
def bootpxe(persistent = true)
|
52
|
+
bootdevice("PXE", persistent)
|
68
53
|
end
|
69
54
|
|
70
55
|
# shortcut to set boot device to disk
|
71
|
-
def bootdisk(persistent=true)
|
72
|
-
bootdevice("HARD-DRIVE",persistent)
|
56
|
+
def bootdisk(persistent = true)
|
57
|
+
bootdevice("HARD-DRIVE", persistent)
|
73
58
|
end
|
74
59
|
|
75
60
|
# shortcut to set boot device to cdrom
|
76
|
-
def bootcdrom(persistent=true)
|
77
|
-
bootdevice("CD-DVD",persistent)
|
61
|
+
def bootcdrom(persistent = true)
|
62
|
+
bootdevice("CD-DVD", persistent)
|
78
63
|
end
|
79
64
|
|
80
65
|
# shortcut to boot into bios setup
|
81
|
-
def bootbios(persistent=true)
|
82
|
-
bootdevice("BIOS-SETUP",persistent)
|
66
|
+
def bootbios(persistent = true)
|
67
|
+
bootdevice("BIOS-SETUP", persistent)
|
83
68
|
end
|
84
69
|
|
85
70
|
private
|
86
71
|
|
87
|
-
def
|
72
|
+
def set_boot_flag(key, flag, _persistent)
|
88
73
|
@options["key-pair"] = "\"Chassis_Boot_Flags:#{key}=#{flag}\""
|
89
74
|
value = commit
|
90
75
|
@options.delete_notify("key-pair")
|
91
|
-
|
76
|
+
value
|
92
77
|
end
|
93
78
|
end
|
94
79
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
80
|
+
## Possible values: NO-OVERRIDE/PXE/HARD-DRIVE/HARD-DRIVE-SAFE-MODE/
|
81
|
+
## DIAGNOSTIC_PARTITION/CD-DVD/BIOS-SETUP/REMOTE-FLOPPY
|
82
|
+
## PRIMARY-REMOTE-MEDIA/REMOTE-CD-DVD/REMOTE-HARD-DRIVE/FLOPPY
|
83
|
+
end
|
@@ -1,24 +1,17 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class Fru < Rubyipmi::Freeipmi::BaseCommand
|
4
|
-
|
5
3
|
attr_accessor :list
|
6
4
|
|
7
5
|
DEFAULT_FRU = 'default_fru_device'
|
8
6
|
|
9
7
|
def initialize(opts = ObservableHash.new)
|
10
|
-
|
11
|
-
|
8
|
+
super("ipmi-fru", opts)
|
9
|
+
@list = {}
|
12
10
|
end
|
13
11
|
|
14
12
|
def get_from_list(key)
|
15
|
-
|
16
|
-
|
17
|
-
list[DEFAULT_FRU][key]
|
18
|
-
else
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
end
|
13
|
+
return unless list.key?(DEFAULT_FRU)
|
14
|
+
list[DEFAULT_FRU][key] if list[DEFAULT_FRU].key?(key)
|
22
15
|
end
|
23
16
|
|
24
17
|
def manufacturer
|
@@ -40,7 +33,7 @@ module Rubyipmi::Freeipmi
|
|
40
33
|
# method to retrieve the raw fru data
|
41
34
|
def getfrus
|
42
35
|
command
|
43
|
-
|
36
|
+
@result
|
44
37
|
end
|
45
38
|
|
46
39
|
def names
|
@@ -49,15 +42,13 @@ module Rubyipmi::Freeipmi
|
|
49
42
|
|
50
43
|
# return the list of fru information in a hash
|
51
44
|
def list
|
52
|
-
if @list.count < 1
|
53
|
-
parse(getfrus)
|
54
|
-
end
|
45
|
+
parse(getfrus) if @list.count < 1
|
55
46
|
@list
|
56
47
|
end
|
57
48
|
|
58
49
|
private
|
59
50
|
|
60
|
-
def method_missing(method, *
|
51
|
+
def method_missing(method, *_args, &_block)
|
61
52
|
name = method.to_s
|
62
53
|
fru = list.fetch(name, nil)
|
63
54
|
# if the user wanted some data from the default fru, lets show the data for the fru. Otherwise
|
@@ -76,7 +67,7 @@ module Rubyipmi::Freeipmi
|
|
76
67
|
|
77
68
|
# parse the fru information
|
78
69
|
def parse(data)
|
79
|
-
if !
|
70
|
+
if !data.nil? && !data.empty?
|
80
71
|
parsed_data = []
|
81
72
|
data.lines.each do |line|
|
82
73
|
if line =~ /^FRU.*/
|
@@ -87,7 +78,6 @@ module Rubyipmi::Freeipmi
|
|
87
78
|
parsed_data = []
|
88
79
|
@list[new_fru[:name]] = new_fru
|
89
80
|
end
|
90
|
-
|
91
81
|
end
|
92
82
|
parsed_data << line
|
93
83
|
end
|
@@ -99,21 +89,17 @@ module Rubyipmi::Freeipmi
|
|
99
89
|
@list[new_fru[:name]] = new_fru
|
100
90
|
end
|
101
91
|
end
|
102
|
-
|
92
|
+
@list
|
103
93
|
end
|
104
94
|
|
105
95
|
# run the command and return result
|
106
96
|
def command
|
107
|
-
|
108
|
-
|
109
|
-
return @result
|
110
|
-
end
|
97
|
+
value = runcmd
|
98
|
+
return @result if value
|
111
99
|
end
|
112
|
-
|
113
100
|
end
|
114
101
|
|
115
102
|
class FruData < Hash
|
116
|
-
|
117
103
|
def name
|
118
104
|
self[:name]
|
119
105
|
end
|
@@ -124,29 +110,24 @@ module Rubyipmi::Freeipmi
|
|
124
110
|
|
125
111
|
# parse the fru information that should be an array of lines
|
126
112
|
def parse(data)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
else
|
135
|
-
key = key.strip.gsub(/\ /, '_').downcase.gsub(/fru_/, '')
|
136
|
-
if ! value.nil?
|
137
|
-
self[key] = value.strip
|
138
|
-
|
139
|
-
end
|
113
|
+
return unless data
|
114
|
+
data.each do |line|
|
115
|
+
key, value = line.split(':', 2)
|
116
|
+
if key =~ /^FRU.*/
|
117
|
+
if value =~ /([\w\s]*)\(.*\)/
|
118
|
+
self[:name] = $~[1].strip.gsub(/\ /, '_').downcase
|
140
119
|
end
|
120
|
+
else
|
121
|
+
key = key.strip.gsub(/\ /, '_').downcase.gsub(/fru_/, '')
|
122
|
+
self[key] = value.strip unless value.nil?
|
141
123
|
end
|
142
124
|
end
|
143
125
|
end
|
144
126
|
|
145
127
|
private
|
146
128
|
|
147
|
-
def method_missing(method, *
|
148
|
-
|
129
|
+
def method_missing(method, *_args, &_block)
|
130
|
+
fetch(method.to_s, nil)
|
149
131
|
end
|
150
|
-
|
151
132
|
end
|
152
|
-
end
|
133
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Rubyipmi::Freeipmi
|
2
|
-
|
3
2
|
class Lan
|
4
|
-
|
5
3
|
attr_accessor :info
|
6
4
|
attr_accessor :channel
|
7
5
|
attr_accessor :config
|
@@ -22,11 +20,11 @@ module Rubyipmi::Freeipmi
|
|
22
20
|
end
|
23
21
|
|
24
22
|
def dhcp?
|
25
|
-
info.fetch("ip_address_source",nil).match(/dhcp/i) != nil
|
23
|
+
info.fetch("ip_address_source", nil).match(/dhcp/i) != nil
|
26
24
|
end
|
27
25
|
|
28
26
|
def static?
|
29
|
-
info.fetch("ip_address_source",nil).match(/static/i) != nil
|
27
|
+
info.fetch("ip_address_source", nil).match(/static/i) != nil
|
30
28
|
end
|
31
29
|
|
32
30
|
def ip
|
@@ -87,7 +85,7 @@ module Rubyipmi::Freeipmi
|
|
87
85
|
# end
|
88
86
|
|
89
87
|
def parse(landata)
|
90
|
-
if !
|
88
|
+
if !landata.nil? && !landata.empty?
|
91
89
|
landata.lines.each do |line|
|
92
90
|
# clean up the data from spaces
|
93
91
|
next if line.match(/#+/)
|
@@ -102,4 +100,4 @@ module Rubyipmi::Freeipmi
|
|
102
100
|
@info
|
103
101
|
end
|
104
102
|
end
|
105
|
-
end
|
103
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
require 'rubyipmi/commands/mixins/power_mixin'
|
2
|
+
|
1
3
|
module Rubyipmi::Freeipmi
|
2
4
|
class Power < Rubyipmi::Freeipmi::BaseCommand
|
5
|
+
include Rubyipmi::PowerMixin
|
3
6
|
|
4
7
|
def initialize(opts = ObservableHash.new)
|
5
8
|
super("ipmipower", opts)
|
@@ -8,65 +11,19 @@ module Rubyipmi::Freeipmi
|
|
8
11
|
# The command function is a wrapper that actually calls the run method
|
9
12
|
def command(opt)
|
10
13
|
@options[opt] = false
|
11
|
-
|
14
|
+
runcmd
|
12
15
|
@options.delete_notify(opt)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Turn on the system
|
17
|
-
def on
|
18
|
-
command("on")
|
19
|
-
end
|
20
|
-
|
21
|
-
# Turn off the system
|
22
|
-
def off
|
23
|
-
command("off")
|
24
|
-
end
|
25
|
-
|
26
|
-
# Power cycle the system
|
27
|
-
def cycle
|
28
|
-
# if the system is off turn it on
|
29
|
-
if off?
|
30
|
-
on
|
31
|
-
else
|
32
|
-
command("cycle")
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
# Perform a power reset on the system
|
38
|
-
def reset
|
39
|
-
command("reset")
|
16
|
+
@result
|
40
17
|
end
|
41
18
|
|
42
|
-
|
43
|
-
def softShutdown
|
44
|
-
command("soft")
|
45
|
-
end
|
46
|
-
|
47
|
-
def powerInterrupt
|
19
|
+
def power_interrupt
|
48
20
|
command("pulse")
|
49
21
|
end
|
50
22
|
|
51
23
|
# Get the power status of the system, will show either on or off
|
52
24
|
def status
|
53
25
|
value = command("stat")
|
54
|
-
if value
|
55
|
-
@result.split(":").last.chomp.strip
|
56
|
-
end
|
26
|
+
@result.split(":").last.chomp.strip if value
|
57
27
|
end
|
58
|
-
|
59
|
-
# Test to see if the power is on
|
60
|
-
def on?
|
61
|
-
status == "on"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Test to see if the power is off
|
65
|
-
def off?
|
66
|
-
status == "off"
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
28
|
end
|
72
|
-
end
|
29
|
+
end
|