rubyipmi 0.8.1 → 0.9.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -8
  3. data/README.md +92 -27
  4. data/Rakefile +1 -6
  5. data/VERSION +1 -1
  6. data/lib/rubyipmi.rb +69 -30
  7. data/lib/rubyipmi/commands/basecommand.rb +16 -18
  8. data/lib/rubyipmi/freeipmi/commands/basecommand.rb +2 -4
  9. data/lib/rubyipmi/freeipmi/commands/bmc.rb +7 -0
  10. data/lib/rubyipmi/freeipmi/commands/bmcconfig.rb +10 -0
  11. data/lib/rubyipmi/freeipmi/commands/bmcdevice.rb +1 -0
  12. data/lib/rubyipmi/freeipmi/commands/bmcinfo.rb +0 -3
  13. data/lib/rubyipmi/freeipmi/commands/chassis.rb +1 -0
  14. data/lib/rubyipmi/freeipmi/commands/chassisconfig.rb +0 -2
  15. data/lib/rubyipmi/freeipmi/commands/fru.rb +0 -1
  16. data/lib/rubyipmi/freeipmi/commands/lan.rb +22 -23
  17. data/lib/rubyipmi/freeipmi/commands/sensors.rb +8 -7
  18. data/lib/rubyipmi/freeipmi/connection.rb +14 -19
  19. data/lib/rubyipmi/freeipmi/errorcodes.rb +0 -1
  20. data/lib/rubyipmi/ipmitool/commands/basecommand.rb +0 -3
  21. data/lib/rubyipmi/ipmitool/commands/bmc.rb +8 -0
  22. data/lib/rubyipmi/ipmitool/commands/chassis.rb +1 -0
  23. data/lib/rubyipmi/ipmitool/commands/fru.rb +0 -7
  24. data/lib/rubyipmi/ipmitool/connection.rb +12 -13
  25. data/lib/rubyipmi/ipmitool/errorcodes.rb +2 -1
  26. data/rubyipmi.gemspec +21 -14
  27. data/spec/integration/bmc_spec.rb +9 -10
  28. data/spec/integration/chassis_config_spec.rb +6 -8
  29. data/spec/integration/chassis_spec.rb +3 -3
  30. data/spec/integration/connection_spec.rb +16 -15
  31. data/spec/integration/fru_spec.rb +6 -7
  32. data/spec/integration/lan_spec.rb +21 -34
  33. data/spec/integration/power_spec.rb +5 -5
  34. data/spec/integration/rubyipmi_spec.rb +63 -9
  35. data/spec/integration/sensor_spec.rb +7 -8
  36. data/spec/spec_helper.rb +10 -7
  37. data/spec/unit/freeipmi/bmc-info_spec.rb +5 -6
  38. data/spec/unit/freeipmi/bmc_spec.rb +8 -9
  39. data/spec/unit/freeipmi/connection_spec.rb +41 -23
  40. data/spec/unit/freeipmi/errorcodes_spec.rb +4 -10
  41. data/spec/unit/freeipmi/fru_spec.rb +15 -16
  42. data/spec/unit/freeipmi/sensors_spec.rb +17 -15
  43. data/spec/unit/ipmitool/bmc_spec.rb +11 -12
  44. data/spec/unit/ipmitool/connection_spec.rb +43 -21
  45. data/spec/unit/ipmitool/errorcodes_spec.rb +5 -4
  46. data/spec/unit/ipmitool/fru_spec.rb +15 -15
  47. data/spec/unit/ipmitool/lan_spec.rb +16 -15
  48. data/spec/unit/ipmitool/sensors_spec.rb +16 -15
  49. data/spec/unit/rubyipmi_spec.rb +6 -6
  50. metadata +64 -24
  51. data/README.rdoc +0 -18
@@ -1,5 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
1
+ require 'spec_helper'
3
2
  describe :Fru do
4
3
 
5
4
  before :all do
@@ -14,7 +13,7 @@ describe :Fru do
14
13
  user = "ipmiuser"
15
14
  pass = "impipass"
16
15
  host = "ipmihost"
17
- Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
16
+ allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
18
17
 
19
18
  @conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
20
19
  @fru = @conn.fru
@@ -22,9 +21,9 @@ describe :Fru do
22
21
  data = file.read
23
22
  end
24
23
 
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)
24
+ allow(@fru).to receive(:locate_command).with('ipmi-fru').and_return("#{@path}/ipmi-fru")
25
+ allow(@fru).to receive(:`).and_return(data)
26
+ allow($?).to receive(:success?).and_return(true)
28
27
  end
29
28
 
30
29
  it "cmd should be ipmi-fru with correct number of arguments" do
@@ -33,43 +32,43 @@ describe :Fru do
33
32
  end
34
33
 
35
34
  it 'should list data' do
36
- @fru.names.count.should eq(1)
35
+ expect(@fru.names.count).to eq(1)
37
36
  end
38
37
 
39
38
  it 'should return a list of unparsed frus' do
40
- @fru.getfrus.should_not be_nil
39
+ expect(@fru.getfrus).not_to be_nil
41
40
  end
42
41
 
43
42
 
44
43
  it "should return a list of parsed frus" do
45
- @fru.list.count.should eq(1)
44
+ expect(@fru.list.count).to eq(1)
46
45
  end
47
46
 
48
47
  it 'should return a manufacturer' do
49
- @fru.board_manufacturer.should eq('HP')
48
+ expect(@fru.board_manufacturer).to eq('HP')
50
49
  end
51
50
 
52
51
  it 'should return a product' do
53
- @fru.board_product_name.should eq('ProLiant DL380 G5')
52
+ expect(@fru.board_product_name).to eq('ProLiant DL380 G5')
54
53
  end
55
54
 
56
55
  it 'should return a chassis serial' do
57
- @fru.chassis_serial_number.should eq('2UX64201U2')
56
+ expect(@fru.chassis_serial_number).to eq('2UX64201U2')
58
57
  end
59
58
 
60
59
  it 'should return a board serial' do
61
- @fru.board_serial_number.should eq('2UX64201U2')
60
+ expect(@fru.board_serial_number).to eq('2UX64201U2')
62
61
  end
63
62
 
64
63
  it 'should return a list of fru names' do
65
- @fru.names.count.should eq(1)
64
+ expect(@fru.names.count).to eq(1)
66
65
  end
67
66
 
68
67
  it 'should return a fru using method missing' do
69
68
  @fru.names.each do |name|
70
69
  fru = @fru.send(name)
71
- fru.should be_an_instance_of(Rubyipmi::Freeipmi::FruData)
72
- fru[:name].should eq(name)
70
+ expect(fru).to be_an_instance_of(Rubyipmi::Freeipmi::FruData)
71
+ expect(fru[:name]).to eq(name)
73
72
 
74
73
  end
75
74
  end
@@ -1,4 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
+
3
+
2
4
  describe :Sensors do
3
5
  before :all do
4
6
  @path = '/usr/local/bin'
@@ -12,7 +14,7 @@ describe :Sensors do
12
14
  pass = "impipass"
13
15
  host = "ipmihost"
14
16
  # 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")
17
+ allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
16
18
 
17
19
  @conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
18
20
  @sensors = @conn.sensors
@@ -20,11 +22,11 @@ describe :Sensors do
20
22
  data = file.read
21
23
  end
22
24
  # 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')
25
+ allow(@sensors).to receive(:locate_command).with('ipmi-sensors').and_return('/usr/local/bin/ipmi-sensors')
24
26
 
25
27
  # 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
+ allow(@sensors).to receive(:`).and_return(data)
29
+ allow($?).to receive(:success?).and_return(true)
28
30
 
29
31
  end
30
32
 
@@ -34,36 +36,36 @@ describe :Sensors do
34
36
  end
35
37
 
36
38
  it "can return a list of sensors" do
37
- @sensors.list.should_not be_nil
39
+ expect(@sensors.list).not_to be_nil
38
40
  end
39
41
 
40
42
  it "should return a count of sensors" do
41
- @sensors.count.should eq(29)
43
+ expect(@sensors.count).to eq(29)
42
44
  end
43
45
 
44
46
  it "should return a list of fan names" do
45
- @sensors.fanlist.count.should eq(13)
47
+ expect(@sensors.fanlist.count).to eq(13)
46
48
  end
47
49
 
48
50
  it 'should return a list of temp names' do
49
- @sensors.templist.count.should.should eq(7)
51
+ expect(@sensors.templist.count).to eq(7)
50
52
  end
51
53
 
52
54
  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
+ expect(@sensors.names).to be_an_instance_of(Array)
56
+ expect(@sensors.names.count).to eq(29)
55
57
  end
56
58
 
57
59
  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
+ allow(@sensors).to receive(:getsensors).and_return(nil)
61
+ expect(@sensors.names.count).to eq(0)
60
62
  end
61
63
 
62
64
  it 'should return a sensor using method missing' do
63
65
  @sensors.names.each do |name|
64
66
  sensor = @sensors.send(name)
65
- sensor.should be_an_instance_of(Rubyipmi::Freeipmi::Sensor)
66
- sensor[:name].should eq(name)
67
+ expect(sensor).to be_an_instance_of(Rubyipmi::Freeipmi::Sensor)
68
+ expect(sensor[:name]).to eq(name)
67
69
  end
68
70
  end
69
71
 
@@ -1,5 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
1
+ require 'spec_helper'
3
2
 
4
3
 
5
4
  describe "Bmc" do
@@ -14,7 +13,7 @@ describe "Bmc" do
14
13
  user = "ipmiuser"
15
14
  pass = "impipass"
16
15
  host = "ipmihost"
17
- Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
16
+ allow(Rubyipmi).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
18
17
  @conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
19
18
  @bmc = @conn.bmc
20
19
  data = nil
@@ -22,32 +21,32 @@ describe "Bmc" do
22
21
  data = file.read
23
22
  end
24
23
 
25
- @bmc.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
26
- @bmc.stub(:`).and_return(data)
27
- $?.stub(:success?).and_return(true)
24
+ allow(@bmc).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
25
+ allow(@bmc).to receive(:`).and_return(data)
26
+ allow($?).to receive(:success?).and_return(true)
28
27
 
29
- @bmc.stub(:guid).and_return("guid")
28
+ allow(@bmc).to receive(:guid).and_return("guid")
30
29
 
31
30
  end
32
31
 
33
32
  it "bmc should not be nil" do
34
- @bmc.should_not be nil
33
+ expect(@bmc).not_to be nil
35
34
  end
36
35
 
37
36
  it "lan should not be nil" do
38
- @bmc.lan.should_not be_nil
37
+ expect(@bmc.lan).not_to be_nil
39
38
  end
40
39
 
41
40
  it "guid should not be nil" do
42
- @bmc.guid.should_not be_nil
41
+ expect(@bmc.guid).not_to be_nil
43
42
  end
44
43
 
45
44
  it "info should not be nil" do
46
- @bmc.info.should_not be_nil
45
+ expect(@bmc.info).not_to be_nil
47
46
  end
48
47
 
49
48
  it "info should parse as expected" do
50
- @bmc.info.should eq(RETRIEVE)
49
+ expect(@bmc.info).to eq(RETRIEVE)
51
50
  end
52
51
 
53
52
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe :Connection do
4
4
 
@@ -12,55 +12,51 @@ describe :Connection do
12
12
 
13
13
  before :each do
14
14
 
15
- Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
15
+ allow(Rubyipmi).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
16
16
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
17
17
 
18
18
  end
19
19
 
20
20
  it "connection should not be nil" do
21
- @conn.should_not be_nil
21
+ expect(@conn).not_to be_nil
22
22
  end
23
23
 
24
24
  it "fru should not be nil" do
25
- @conn.fru.should_not be_nil
25
+ expect(@conn.fru).not_to be_nil
26
26
  end
27
27
 
28
28
  it "provider should not be nil" do
29
- @conn.provider.should_not be_nil
29
+ expect(@conn.provider).not_to be_nil
30
30
  end
31
31
 
32
32
  it "provider should be ipmitool" do
33
- @conn.provider.should == "ipmitool"
33
+ expect(@conn.provider).to eq("ipmitool")
34
34
  end
35
35
 
36
36
  it "bmc should not be nil" do
37
- @conn.bmc.should_not be_nil
37
+ expect(@conn.bmc).not_to be_nil
38
38
  end
39
39
 
40
40
  it "sensors should not be nil" do
41
- @conn.sensors.should_not be_nil
41
+ expect(@conn.sensors).not_to be_nil
42
42
 
43
43
  end
44
44
 
45
45
  it "chassis should not be nill" do
46
- @conn.chassis.should_not be_nil
46
+ expect(@conn.chassis).not_to be_nil
47
47
  end
48
48
 
49
49
  it "provider should return ipmitool" do
50
- @conn.provider.should eq("ipmitool")
51
- end
52
-
53
- it "debug value should be true" do
54
- @conn.debug.should be_true
50
+ expect(@conn.provider).to eq("ipmitool")
55
51
  end
56
52
 
57
53
  it 'object should have driver set to auto if not specified' do
58
- @conn.options.has_key?('driver-type').should be_false
54
+ expect(@conn.options.has_key?('driver-type')).to eq false
59
55
  end
60
56
 
61
57
  it 'object should have driver set to auto if not specified' do
62
58
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
63
- @conn.options.has_key?('I').should be_false
59
+ expect(@conn.options.has_key?('I')).to eq false
64
60
  end
65
61
 
66
62
  it 'should raise exception if invalid driver type' do
@@ -69,12 +65,12 @@ describe :Connection do
69
65
 
70
66
  it 'object should have priv type set to ADMINISTRATOR if not specified' do
71
67
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
72
- @conn.options.has_key?('L').should be_false
68
+ expect(@conn.options.has_key?('L')).to eq false
73
69
  end
74
70
 
75
71
  it 'object should have priv type set to USER ' do
76
72
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
77
- @conn.options.fetch('L').should eq('USER')
73
+ expect(@conn.options.fetch('L')).to eq('USER')
78
74
  end
79
75
 
80
76
  it 'should raise exception if invalid privilege type' do
@@ -83,17 +79,43 @@ describe :Connection do
83
79
 
84
80
  it 'object should have driver set to lanplus' do
85
81
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
86
- @conn.options['I'].should eq('lanplus')
82
+ expect(@conn.options['I']).to eq('lanplus')
87
83
  end
88
84
 
89
85
  it 'object should have driver set to lanplus' do
90
86
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
91
- @conn.options['I'].should eq('lan')
87
+ expect(@conn.options['I']).to eq('lan')
92
88
  end
93
89
 
94
90
  it 'object should have driver set to open' do
95
91
  @conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
96
- @conn.options['I'].should eq('open')
92
+ expect(@conn.options['I']).to eq('open')
93
+ end
94
+ describe 'test' do
95
+ it 'should retrun boolean on test connection when result is not a hash' do
96
+ conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
97
+ bmc = double()
98
+ allow(bmc).to receive(:info).and_return('')
99
+ allow(conn).to receive(:bmc).and_return(bmc)
100
+ expect(conn.connection_works?).to eq false
101
+ end
102
+
103
+ it 'should retrun boolean on test connection when result is a hash' do
104
+ conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
105
+ bmc = double()
106
+ allow(bmc).to receive(:info).and_return({:test => true})
107
+ allow(conn).to receive(:bmc).and_return(bmc)
108
+ expect(conn.connection_works?).to eq true
109
+ end
110
+
111
+ it 'should retrun boolean on test connection when nil' do
112
+ conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
113
+ bmc = double()
114
+ allow(bmc).to receive(:info).and_return(nil)
115
+ allow(conn).to receive(:bmc).and_return(bmc)
116
+ expect(conn.connection_works?).to eq false
117
+ end
97
118
  end
98
119
 
120
+
99
121
  end
@@ -1,4 +1,5 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
+
2
3
  require 'rubyipmi/ipmitool/errorcodes'
3
4
 
4
5
  describe "Errorcodes" do
@@ -6,17 +7,17 @@ describe "Errorcodes" do
6
7
 
7
8
 
8
9
  it 'should return the length of fix hash' do
9
- Rubyipmi::Ipmitool::ErrorCodes.length.should be > 1
10
+ expect(Rubyipmi::Ipmitool::ErrorCodes.length).to be > 1
10
11
  end
11
12
 
12
13
  it 'should return a hash of codes' do
13
- Rubyipmi::Ipmitool::ErrorCodes.code.should be_an_instance_of Hash
14
+ expect(Rubyipmi::Ipmitool::ErrorCodes.code).to be_an_instance_of Hash
14
15
 
15
16
  end
16
17
 
17
18
  it 'should return a fix if code is found' do
18
19
  code = 'Authentication type NONE not supported'
19
- Rubyipmi::Ipmitool::ErrorCodes.search(code).should eq({"I"=>"lanplus"})
20
+ expect(Rubyipmi::Ipmitool::ErrorCodes.search(code)).to eq({"I"=>"lanplus"})
20
21
  end
21
22
 
22
23
  it 'should throw and error if no fix is found' do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe :Fru do
4
4
 
@@ -13,7 +13,7 @@ describe :Fru do
13
13
  user = "ipmiuser"
14
14
  pass = "impipass"
15
15
  host = "ipmihost"
16
- Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
16
+ allow(Rubyipmi).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
17
17
 
18
18
  @conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
19
19
  @fru = @conn.fru
@@ -22,9 +22,9 @@ describe :Fru do
22
22
  data = file.read
23
23
  end
24
24
 
25
- @fru.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
26
- @fru.stub(:`).and_return(data)
27
- $?.stub(:success?).and_return(true)
25
+ allow(@fru).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
26
+ allow(@fru).to receive(:`).and_return(data)
27
+ allow($?).to receive(:success?).and_return(true)
28
28
 
29
29
  end
30
30
 
@@ -34,42 +34,42 @@ describe :Fru do
34
34
  end
35
35
 
36
36
  it 'should return a list of unparsed frus' do
37
- @fru.getfrus.should_not be_nil
37
+ expect(@fru.getfrus).not_to be_nil
38
38
  end
39
39
 
40
40
  it 'should return a list of fru names' do
41
- @fru.names.count.should eq(13)
41
+ expect(@fru.names.count).to eq(13)
42
42
  end
43
43
 
44
44
  it "should return a list of parsed frus" do
45
- @fru.list.count.should eq(13)
45
+ expect(@fru.list.count).to eq(13)
46
46
  end
47
47
 
48
48
  it 'should return a manufactor' do
49
- @fru.product_manufacturer.should eq('HP')
49
+ expect(@fru.product_manufacturer).to eq('HP')
50
50
  end
51
51
 
52
52
  it 'should return a product' do
53
- @fru.product_name.should eq('ProLiant SL230s Gen8')
53
+ expect(@fru.product_name).to eq('ProLiant SL230s Gen8')
54
54
  end
55
55
 
56
56
  it 'should return a board serial' do
57
- @fru.board_serial.should eq('USE238F0D0')
57
+ expect(@fru.board_serial).to eq('USE238F0D0')
58
58
  end
59
59
 
60
60
  it 'should return a product serial' do
61
- @fru.product_serial.should eq('USE238F0D0')
61
+ expect(@fru.product_serial).to eq('USE238F0D0')
62
62
  end
63
63
 
64
64
  it 'should return a asset tag' do
65
- @fru.product_asset_tag.should eq('000015B90F82')
65
+ expect(@fru.product_asset_tag).to eq('000015B90F82')
66
66
  end
67
67
 
68
68
  it 'should return a fru using method missing' do
69
69
  @fru.names.each do |name|
70
70
  fru = @fru.send(name)
71
- fru.should be_an_instance_of(Rubyipmi::Ipmitool::FruData)
72
- fru[:name].should eq(name)
71
+ expect(fru).to be_an_instance_of(Rubyipmi::Ipmitool::FruData)
72
+ expect(fru[:name]).to eq(name)
73
73
  end
74
74
  end
75
75