rubyipmi 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +5 -3
  3. data/README.md +24 -14
  4. data/Rakefile +82 -4
  5. data/VERSION +1 -1
  6. data/lib/rubyipmi.rb +36 -14
  7. data/lib/rubyipmi/commands/basecommand.rb +57 -119
  8. data/lib/rubyipmi/freeipmi/commands/basecommand.rb +29 -25
  9. data/lib/rubyipmi/freeipmi/commands/bmc.rb +3 -3
  10. data/lib/rubyipmi/freeipmi/commands/bmcconfig.rb +6 -6
  11. data/lib/rubyipmi/freeipmi/commands/bmcinfo.rb +3 -23
  12. data/lib/rubyipmi/freeipmi/commands/fru.rb +117 -23
  13. data/lib/rubyipmi/freeipmi/commands/lan.rb +32 -37
  14. data/lib/rubyipmi/freeipmi/commands/power.rb +1 -1
  15. data/lib/rubyipmi/freeipmi/commands/sensors.rb +53 -50
  16. data/lib/rubyipmi/freeipmi/connection.rb +16 -2
  17. data/lib/rubyipmi/freeipmi/errorcodes.rb +25 -2
  18. data/lib/rubyipmi/ipmitool/commands/basecommand.rb +20 -37
  19. data/lib/rubyipmi/ipmitool/commands/bmc.rb +1 -24
  20. data/lib/rubyipmi/ipmitool/commands/chassis.rb +1 -0
  21. data/lib/rubyipmi/ipmitool/commands/fru.rb +112 -30
  22. data/lib/rubyipmi/ipmitool/commands/lan.rb +55 -77
  23. data/lib/rubyipmi/ipmitool/commands/power.rb +10 -4
  24. data/lib/rubyipmi/ipmitool/commands/sensors.rb +53 -80
  25. data/lib/rubyipmi/ipmitool/connection.rb +19 -3
  26. data/lib/rubyipmi/ipmitool/errorcodes.rb +51 -3
  27. data/rubyipmi.gemspec +73 -33
  28. data/spec/Vagrantfile +45 -0
  29. data/spec/fixtures/freeipmi/bmc_config.txt +317 -0
  30. data/spec/fixtures/freeipmi/bmc_config_lan_conf.txt +19 -0
  31. data/spec/fixtures/freeipmi/bmc_info.txt +32 -0
  32. data/spec/fixtures/freeipmi/errors.txt +3 -0
  33. data/spec/fixtures/freeipmi/fru.txt +13 -0
  34. data/spec/fixtures/freeipmi/sensors.txt +29 -0
  35. data/spec/fixtures/ipmitool/bmc_info.txt +20 -0
  36. data/spec/fixtures/ipmitool/errors.txt +10 -0
  37. data/spec/fixtures/ipmitool/fru.txt +96 -0
  38. data/spec/fixtures/ipmitool/lan.txt +17 -0
  39. data/spec/fixtures/ipmitool/sensors.txt +105 -0
  40. data/spec/integration/bmc_spec.rb +49 -0
  41. data/spec/{chassis_config_spec.rb → integration/chassis_config_spec.rb} +6 -6
  42. data/spec/integration/chassis_spec.rb +26 -0
  43. data/spec/integration/connection_spec.rb +35 -0
  44. data/spec/{fru_spec.rb → integration/fru_spec.rb} +11 -10
  45. data/spec/{lan_spec.rb → integration/lan_spec.rb} +9 -7
  46. data/spec/integration/power_spec.rb +40 -0
  47. data/spec/{rubyipmi_spec.rb → integration/rubyipmi_spec.rb} +7 -10
  48. data/spec/{sensor_spec.rb → integration/sensor_spec.rb} +5 -20
  49. data/spec/manifests/default.pp +50 -0
  50. data/spec/puppetmodules/archive/LICENSE-2.0.txt +202 -0
  51. data/spec/puppetmodules/archive/Modulefile +8 -0
  52. data/spec/puppetmodules/archive/README.md +40 -0
  53. data/spec/puppetmodules/archive/manifests/download.pp +157 -0
  54. data/spec/puppetmodules/archive/manifests/extract.pp +81 -0
  55. data/spec/puppetmodules/archive/manifests/init.pp +70 -0
  56. data/spec/puppetmodules/archive/manifests/tar-gz.pp +7 -0
  57. data/spec/puppetmodules/archive/manifests/zip.pp +7 -0
  58. data/spec/puppetmodules/archive/metadata.json +26 -0
  59. data/spec/spec_helper.rb +35 -3
  60. data/spec/unit/freeipmi/bmc-info_spec.rb +42 -0
  61. data/spec/unit/freeipmi/bmc_spec.rb +44 -0
  62. data/spec/unit/freeipmi/connection_spec.rb +56 -0
  63. data/spec/unit/freeipmi/errorcodes_spec.rb +34 -0
  64. data/spec/unit/freeipmi/fru_spec.rb +77 -0
  65. data/spec/unit/freeipmi/lan_spec.rb +0 -0
  66. data/spec/unit/freeipmi/sensors_spec.rb +83 -0
  67. data/spec/unit/ipmitool/bmc_spec.rb +78 -0
  68. data/spec/unit/ipmitool/connection_spec.rb +58 -0
  69. data/spec/unit/ipmitool/errorcodes_spec.rb +34 -0
  70. data/spec/unit/ipmitool/fru_spec.rb +77 -0
  71. data/spec/unit/ipmitool/lan_spec.rb +93 -0
  72. data/spec/unit/ipmitool/sensors_spec.rb +95 -0
  73. data/spec/unit/rubyipmi_spec.rb +31 -0
  74. data/spec/vagrant +27 -0
  75. data/spec/vagrant.pub +1 -0
  76. metadata +157 -106
  77. data/.document +0 -5
  78. data/.rspec +0 -1
  79. data/Gemfile.lock +0 -33
  80. data/spec/bmc_spec.rb +0 -46
  81. data/spec/chassis_spec.rb +0 -26
  82. data/spec/connection_spec.rb +0 -31
  83. data/spec/power_spec.rb +0 -42
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+
5
+ describe "Bmc" do
6
+ before :all do
7
+ @path = '/usr/local/bin'
8
+ end
9
+
10
+ before :each do
11
+ allow_message_expectations_on_nil
12
+ provider = "freeipmi"
13
+ user = "ipmiuser"
14
+ pass = "impipass"
15
+ host = "ipmihost"
16
+ Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
17
+
18
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
19
+ @bmcinfo = @conn.bmc.information
20
+ data = nil
21
+ File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
22
+ data = file.read
23
+ end
24
+ @bmcinfo.stub(:locate_command).with('bmc-info').and_return("#{@path}/bmc-info")
25
+ @bmcinfo.stub(:`).and_return(data)
26
+ $?.stub(:success?).and_return(true)
27
+ end
28
+
29
+ it "cmd should be bmc-info with correct number of arguments" do
30
+ @bmcinfo.retrieve
31
+ verify_freeipmi_command(@bmcinfo, 2, "#{@path}/bmc-info")
32
+ end
33
+
34
+ it "cmd should be bmc-info with correct number of arguments" do
35
+ @bmcinfo.guid
36
+ verify_freeipmi_command(@bmcinfo, 3, "#{@path}/bmc-info")
37
+ end
38
+
39
+
40
+
41
+
42
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+
5
+ describe "Bmc" do
6
+ before :all do
7
+ @path = '/usr/local/bin'
8
+ end
9
+
10
+ before :each do
11
+ allow_message_expectations_on_nil
12
+ provider = "freeipmi"
13
+ user = "ipmiuser"
14
+ pass = "impipass"
15
+ host = "ipmihost"
16
+ Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
17
+
18
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
19
+ @bmc = @conn.bmc
20
+ data = nil
21
+ File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
22
+ data = file.read
23
+ end
24
+ @bmc.stub(:guid).and_return("guid")
25
+ @bmc.stub(:info).and_return("info")
26
+ end
27
+
28
+ it "bmc should not be nil" do
29
+ @bmc.should_not be nil
30
+ end
31
+
32
+ it "lan should not be nil" do
33
+ @bmc.lan.should_not be_nil
34
+ end
35
+
36
+ it "guid should not be nil" do
37
+ @bmc.guid.should_not be_nil
38
+ end
39
+
40
+ it "info should not be nill" do
41
+ @bmc.info.should_not be_nil
42
+ end
43
+
44
+ end
@@ -0,0 +1,56 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ require 'spec_helper'
4
+
5
+
6
+ describe "Bmc" do
7
+
8
+ before :all do
9
+ @path = '/usr/local/bin'
10
+ end
11
+
12
+ before :each do
13
+
14
+ provider = "freeipmi"
15
+ user = "ipmiuser"
16
+ pass = "impipass"
17
+ host = "ipmihost"
18
+ Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
19
+
20
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
21
+
22
+
23
+ end
24
+
25
+ it "connection should not be nil" do
26
+ @conn.should_not be_nil
27
+ end
28
+
29
+ it "fru should not be nil" do
30
+ @conn.fru.should_not be_nil
31
+ end
32
+
33
+ it "provider should not be nil" do
34
+ @conn.provider.should_not be_nil
35
+ end
36
+
37
+ it "provider should be freeipmi" do
38
+ @conn.provider.should == "freeipmi"
39
+ end
40
+
41
+ it "bmc should not be nil" do
42
+ @conn.bmc.should_not be_nil
43
+ end
44
+
45
+ it "sensors should not be nil" do
46
+ @conn.sensors.should_not be_nil
47
+
48
+ end
49
+
50
+ it "chassis should not be nill" do
51
+ @conn.chassis.should_not be_nil
52
+
53
+ end
54
+
55
+
56
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ #require 'rubyipmi/Freeipmi/errorcodes'
3
+
4
+ describe "Errorcodes" do
5
+
6
+
7
+
8
+ it 'should return the length of fix hash' do
9
+ Rubyipmi::Freeipmi::ErrorCodes.length.should be >= 1
10
+ end
11
+
12
+ it 'should return a hash of codes' do
13
+ Rubyipmi::Freeipmi::ErrorCodes.code.should be_an_instance_of Hash
14
+
15
+ end
16
+
17
+ it 'should return a fix if code is found' do
18
+ code = 'authentication type unavailable for attempted privilege level'
19
+ Rubyipmi::Freeipmi::ErrorCodes.search(code).should eq({"driver-type" => "LAN_2_0"})
20
+ end
21
+
22
+ it 'should throw and error if no fix is found' do
23
+ code = 'Crap Shoot'
24
+ expect {Rubyipmi::Freeipmi::ErrorCodes.search(code)}.to raise_error
25
+ end
26
+
27
+ it 'should throw and error when a bad code is given' do
28
+ code = nil
29
+ expect {Rubyipmi::Freeipmi::ErrorCodes.search(code)}.to raise_error
30
+ end
31
+
32
+
33
+
34
+ end
@@ -0,0 +1,77 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe :Fru do
4
+
5
+ before :all do
6
+ @path = '/usr/local/bin'
7
+ end
8
+
9
+ before :each do
10
+
11
+ allow_message_expectations_on_nil
12
+ data = nil
13
+ provider = "freeipmi"
14
+ user = "ipmiuser"
15
+ pass = "impipass"
16
+ host = "ipmihost"
17
+ Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
18
+
19
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
20
+ @fru = @conn.fru
21
+ File.open("spec/fixtures/#{provider}/fru.txt",'r') do |file|
22
+ data = file.read
23
+ end
24
+
25
+ @fru.stub(:locate_command).with('ipmi-fru').and_return("#{@path}/ipmi-fru")
26
+ @fru.stub(:`).and_return(data)
27
+ $?.stub(:success?).and_return(true)
28
+ end
29
+
30
+ it "cmd should be ipmi-fru with correct number of arguments" do
31
+ @fru.list
32
+ verify_freeipmi_command(@fru, 2, "#{@path}/ipmi-fru")
33
+ end
34
+
35
+ it 'should list data' do
36
+ @fru.names.count.should eq(1)
37
+ end
38
+
39
+ it 'should return a list of unparsed frus' do
40
+ @fru.getfrus.should_not be_nil
41
+ end
42
+
43
+
44
+ it "should return a list of parsed frus" do
45
+ @fru.list.count.should eq(1)
46
+ end
47
+
48
+ it 'should return a manufacturer' do
49
+ @fru.board_manufacturer.should eq('HP')
50
+ end
51
+
52
+ it 'should return a product' do
53
+ @fru.board_product_name.should eq('ProLiant DL380 G5')
54
+ end
55
+
56
+ it 'should return a chassis serial' do
57
+ @fru.chassis_serial_number.should eq('2UX64201U2')
58
+ end
59
+
60
+ it 'should return a board serial' do
61
+ @fru.board_serial_number.should eq('2UX64201U2')
62
+ end
63
+
64
+ it 'should return a list of fru names' do
65
+ @fru.names.count.should eq(1)
66
+ end
67
+
68
+ it 'should return a fru using method missing' do
69
+ @fru.names.each do |name|
70
+ fru = @fru.send(name)
71
+ fru.should be_an_instance_of(Rubyipmi::Freeipmi::FruData)
72
+ fru[:name].should eq(name)
73
+
74
+ end
75
+ end
76
+
77
+ end
File without changes
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ describe :Sensors do
3
+ before :all do
4
+ @path = '/usr/local/bin'
5
+ end
6
+
7
+ before :each do
8
+ allow_message_expectations_on_nil
9
+ data = nil
10
+ provider = "freeipmi"
11
+ user = "ipmiuser"
12
+ pass = "impipass"
13
+ host = "ipmihost"
14
+ # this stub allows us to mock the command that would be used to verify provider installation
15
+ Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
16
+
17
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
18
+ @sensors = @conn.sensors
19
+ File.open("spec/fixtures/#{provider}/sensors.txt",'r') do |file|
20
+ data = file.read
21
+ end
22
+ # this stub allows us to mock the command that is used with this test case
23
+ @sensors.stub(:locate_command).with('ipmi-sensors').and_return('/usr/local/bin/ipmi-sensors')
24
+
25
+ # these stubs allow us to run the command and return the fixtures
26
+ @sensors.stub(:`).and_return(data)
27
+ $?.stub(:success?).and_return(true)
28
+
29
+ end
30
+
31
+ it "cmd should be ipmi-sensors with six arguments" do
32
+ @sensors.list
33
+ verify_freeipmi_command(@sensors, 5, "#{@path}/ipmi-sensors")
34
+ end
35
+
36
+ it "can return a list of sensors" do
37
+ @sensors.list.should_not be_nil
38
+ end
39
+
40
+ it "should return a count of sensors" do
41
+ @sensors.count.should eq(29)
42
+ end
43
+
44
+ it "should return a list of fan names" do
45
+ @sensors.fanlist.count.should eq(13)
46
+ end
47
+
48
+ it 'should return a list of temp names' do
49
+ @sensors.templist.count.should.should eq(7)
50
+ end
51
+
52
+ it 'should return a list of sensor names as an array' do
53
+ @sensors.names.should be_an_instance_of(Array)
54
+ @sensors.names.count.should eq(29)
55
+ end
56
+
57
+ it 'should return an empty list if no data exists' do
58
+ @sensors.stub(:getsensors).and_return(nil)
59
+ @sensors.names.count.should eq(0)
60
+ end
61
+
62
+ it 'should return a sensor using method missing' do
63
+ @sensors.names.each do |name|
64
+ sensor = @sensors.send(name)
65
+ sensor.should be_an_instance_of(Rubyipmi::Freeipmi::Sensor)
66
+ sensor[:name].should eq(name)
67
+ end
68
+ end
69
+
70
+ #it 'fix should be added to options after error occurs' do
71
+ # error = nil
72
+ # File.open("spec/fixtures/freeipmi/errors.txt",'r') do |file|
73
+ # error = file.read
74
+ # end
75
+ # @sensors.stub(:`).and_return(error)
76
+ # $?.stub(:success?).and_return(false)
77
+ # @sensors.refresh
78
+ # after = @sensors.options.fetch('driver-type', false).should_not be_false
79
+ #end
80
+
81
+
82
+ end
83
+
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+
5
+ describe "Bmc" do
6
+
7
+ before :all do
8
+ @path = '/usr/local/bin'
9
+ end
10
+
11
+ before :each do
12
+ allow_message_expectations_on_nil
13
+ provider = "ipmitool"
14
+ user = "ipmiuser"
15
+ pass = "impipass"
16
+ host = "ipmihost"
17
+ Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
18
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
19
+ @bmc = @conn.bmc
20
+ data = nil
21
+ File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
22
+ data = file.read
23
+ end
24
+
25
+ @bmc.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
26
+ @bmc.stub(:`).and_return(data)
27
+ $?.stub(:success?).and_return(true)
28
+
29
+ @bmc.stub(:guid).and_return("guid")
30
+
31
+ end
32
+
33
+ it "bmc should not be nil" do
34
+ @bmc.should_not be nil
35
+ end
36
+
37
+ it "lan should not be nil" do
38
+ @bmc.lan.should_not be_nil
39
+ end
40
+
41
+ it "guid should not be nil" do
42
+ @bmc.guid.should_not be_nil
43
+ end
44
+
45
+ it "info should not be nil" do
46
+ @bmc.info.should_not be_nil
47
+ end
48
+
49
+ it "info should parse as expected" do
50
+ @bmc.info.should eq(RETRIEVE)
51
+ end
52
+
53
+ end
54
+
55
+ RETRIEVE = {
56
+ 'Device ID' => '17',
57
+ 'Device Revision' => '1',
58
+ 'Firmware Revision' => '2.9',
59
+ 'IPMI Version' => '2.0',
60
+ 'Manufacturer ID' => '11',
61
+ 'Manufacturer Name' => 'Hewlett-Packard',
62
+ 'Product ID' => '8192 (0x2000)',
63
+ 'Product Name' => 'Unknown (0x2000)',
64
+ 'Device Available' => 'yes',
65
+ 'Provides Device SDRs' => 'yes',
66
+ 'Additional Device Support' => [
67
+ 'Sensor Device',
68
+ 'SDR Repository Device',
69
+ 'SEL Device',
70
+ 'FRU Inventory Device'
71
+ ],
72
+ 'Aux Firmware Rev Info' => [
73
+ '0x00',
74
+ '0x00',
75
+ '0x00',
76
+ '0x30'
77
+ ]
78
+ }
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe :Connection do
4
+
5
+ before :all do
6
+ @path = '/usr/local/bin'
7
+ end
8
+
9
+ before :each do
10
+ provider = "ipmitool"
11
+ user = "ipmiuser"
12
+ pass = "impipass"
13
+ host = "ipmihost"
14
+ Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
15
+ @conn = Rubyipmi.connect(user, pass, host, provider, true)
16
+
17
+ end
18
+
19
+ it "connection should not be nil" do
20
+ @conn.should_not be_nil
21
+ end
22
+
23
+ it "fru should not be nil" do
24
+ @conn.fru.should_not be_nil
25
+ end
26
+
27
+ it "provider should not be nil" do
28
+ @conn.provider.should_not be_nil
29
+ end
30
+
31
+ it "provider should be ipmitool" do
32
+ @conn.provider.should == "ipmitool"
33
+ end
34
+
35
+ it "bmc should not be nil" do
36
+ @conn.bmc.should_not be_nil
37
+ end
38
+
39
+ it "sensors should not be nil" do
40
+ @conn.sensors.should_not be_nil
41
+
42
+ end
43
+
44
+ it "chassis should not be nill" do
45
+ @conn.chassis.should_not be_nil
46
+ end
47
+
48
+ it "provider should return ipmitool" do
49
+ @conn.provider.should eq("ipmitool")
50
+ end
51
+
52
+ it "debug value should be true" do
53
+ @conn.debug.should be_true
54
+ end
55
+
56
+
57
+
58
+ end