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,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe "Bmc" do
|
5
|
-
before :all do
|
6
|
-
@path = '/usr/local/bin'
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
allow_message_expectations_on_nil
|
11
|
-
provider = "freeipmi"
|
12
|
-
user = "ipmiuser"
|
13
|
-
pass = "impipass"
|
14
|
-
host = "ipmihost"
|
15
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
16
|
-
|
17
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
18
|
-
@bmcinfo = @conn.bmc.information
|
19
|
-
data = nil
|
20
|
-
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
21
|
-
data = file.read
|
22
|
-
end
|
23
|
-
allow(@bmcinfo).to receive(:locate_command).with('bmc-info').and_return("#{@path}/bmc-info")
|
24
|
-
allow(@bmcinfo).to receive(:`).and_return(data)
|
25
|
-
allow($?).to receive(:success?).and_return(true)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "cmd should be bmc-info with correct number of arguments" do
|
29
|
-
@bmcinfo.retrieve
|
30
|
-
verify_freeipmi_command(@bmcinfo, 3, "#{@path}/bmc-info")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "cmd should be bmc-info with correct number of arguments" do
|
34
|
-
@bmcinfo.guid
|
35
|
-
verify_freeipmi_command(@bmcinfo, 4, "#{@path}/bmc-info")
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe "Bmc" do
|
5
|
-
before :all do
|
6
|
-
@path = '/usr/local/bin'
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
allow_message_expectations_on_nil
|
11
|
-
provider = "freeipmi"
|
12
|
-
user = "ipmiuser"
|
13
|
-
pass = "impipass"
|
14
|
-
host = "ipmihost"
|
15
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
16
|
-
|
17
|
-
@conn = Rubyipmi.connect(user, pass, host, provider,{:debug => true})
|
18
|
-
@bmc = @conn.bmc
|
19
|
-
data = nil
|
20
|
-
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
21
|
-
data = file.read
|
22
|
-
end
|
23
|
-
allow(@bmc).to receive(:guid).and_return("guid")
|
24
|
-
allow(@bmc).to receive(:info).and_return("info")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "bmc should not be nil" do
|
28
|
-
expect(@bmc).not_to be nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it "lan should not be nil" do
|
32
|
-
expect(@bmc.lan).not_to be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it "guid should not be nil" do
|
36
|
-
expect(@bmc.guid).not_to be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it "info should not be nill" do
|
40
|
-
expect(@bmc.info).not_to be_nil
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Bmc" do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@path = '/usr/local/bin'
|
7
|
-
@provider = "freeipmi"
|
8
|
-
@user = "ipmiuser"
|
9
|
-
@pass = "impipass"
|
10
|
-
@host = "ipmihost"
|
11
|
-
end
|
12
|
-
|
13
|
-
before :each do
|
14
|
-
|
15
|
-
|
16
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
|
-
|
18
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
it "connection should not be nil" do
|
24
|
-
expect(@conn).not_to be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "fru should not be nil" do
|
28
|
-
expect(@conn.fru).not_to be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it "provider should not be nil" do
|
32
|
-
expect(@conn.provider).not_to be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it "provider should be freeipmi" do
|
36
|
-
expect(@conn.provider).to eq("freeipmi")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "bmc should not be nil" do
|
40
|
-
expect(@conn.bmc).not_to be_nil
|
41
|
-
end
|
42
|
-
|
43
|
-
it "sensors should not be nil" do
|
44
|
-
expect(@conn.sensors).not_to be_nil
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
it "chassis should not be nill" do
|
49
|
-
expect(@conn.chassis).not_to be_nil
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'object should have driver set to lan20 if not specified' do
|
54
|
-
expect(@conn.options['driver-type']).to eq "LAN_2_0"
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'object should have driver set to auto if not specified' do
|
59
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
60
|
-
expect(@conn.options.has_key?('driver-type')).to eq false
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'object should have priv type set to ADMINISTRATOR if not specified' do
|
64
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
65
|
-
expect(@conn.options.has_key?('privilege-level')).to eq false
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'object should have priv type set to USER ' do
|
69
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
|
70
|
-
expect(@conn.options.fetch('privilege-level')).to eq('USER')
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should raise exception if invalid privilege type' do
|
74
|
-
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'BLAH',:debug => true, :driver => 'auto'})}.to raise_error(RuntimeError)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should raise exception if invalid driver type' do
|
78
|
-
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'foo'})}.to raise_error(RuntimeError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'object should have driver set to lan_2_0' do
|
82
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
|
83
|
-
expect(@conn.options['driver-type']).to eq('LAN_2_0')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'object should have driver set to lan' do
|
87
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
|
88
|
-
expect(@conn.options['driver-type']).to eq('LAN')
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'object should have driver set to openipmi' do
|
92
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
|
93
|
-
expect(@conn.options['driver-type']).to eq('OPENIPMI')
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'test' do
|
97
|
-
it 'should retrun boolean on test connection when result is not a hash' do
|
98
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
99
|
-
bmc = double()
|
100
|
-
allow(bmc).to receive(:info).and_return('')
|
101
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
102
|
-
expect(conn.connection_works?).to eq false
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should retrun boolean on test connection when result is a hash' do
|
106
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
107
|
-
bmc = double()
|
108
|
-
allow(bmc).to receive(:info).and_return({:test => true})
|
109
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
110
|
-
expect(conn.connection_works?).to eq true
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should retrun boolean on test connection when nil' do
|
114
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
115
|
-
bmc = double()
|
116
|
-
allow(bmc).to receive(:info).and_return(nil)
|
117
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
118
|
-
expect(conn.connection_works?).to eq false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
#require 'rubyipmi/Freeipmi/errorcodes'
|
3
|
-
|
4
|
-
describe "Errorcodes" do
|
5
|
-
it 'should return the length of fix hash' do
|
6
|
-
expect(Rubyipmi::Freeipmi::ErrorCodes.length).to be >= 1
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should return a hash of codes' do
|
10
|
-
expect(Rubyipmi::Freeipmi::ErrorCodes.code).to be_an_instance_of Hash
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should return a fix if code is found' do
|
15
|
-
code = 'authentication type unavailable for attempted privilege level'
|
16
|
-
expect(Rubyipmi::Freeipmi::ErrorCodes.search(code)).to eq({"driver-type" => "LAN_2_0"})
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should throw and error if no fix is found' do
|
20
|
-
code = 'Crap Shoot'
|
21
|
-
expect {Rubyipmi::Freeipmi::ErrorCodes.search(code)}.to raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should throw and error when a bad code is given' do
|
25
|
-
code = nil
|
26
|
-
expect {Rubyipmi::Freeipmi::ErrorCodes.search(code)}.to raise_error
|
27
|
-
end
|
28
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe :Fru do
|
3
|
-
|
4
|
-
before :all do
|
5
|
-
@path = '/usr/local/bin'
|
6
|
-
end
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
|
10
|
-
allow_message_expectations_on_nil
|
11
|
-
data = nil
|
12
|
-
provider = "freeipmi"
|
13
|
-
user = "ipmiuser"
|
14
|
-
pass = "impipass"
|
15
|
-
host = "ipmihost"
|
16
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
|
-
|
18
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
19
|
-
@fru = @conn.fru
|
20
|
-
File.open("spec/fixtures/#{provider}/fru.txt",'r') do |file|
|
21
|
-
data = file.read
|
22
|
-
end
|
23
|
-
|
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)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "cmd should be ipmi-fru with correct number of arguments" do
|
30
|
-
@fru.list
|
31
|
-
verify_freeipmi_command(@fru, 3, "#{@path}/ipmi-fru")
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should list data' do
|
35
|
-
expect(@fru.names.count).to eq(1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should return a list of unparsed frus' do
|
39
|
-
expect(@fru.getfrus).not_to be_nil
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
it "should return a list of parsed frus" do
|
44
|
-
expect(@fru.list.count).to eq(1)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should return a manufacturer' do
|
48
|
-
expect(@fru.board_manufacturer).to eq('HP')
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should return a product' do
|
52
|
-
expect(@fru.board_product_name).to eq('ProLiant DL380 G5')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should return a chassis serial' do
|
56
|
-
expect(@fru.chassis_serial_number).to eq('2UX64201U2')
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should return a board serial' do
|
60
|
-
expect(@fru.board_serial_number).to eq('2UX64201U2')
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should return a list of fru names' do
|
64
|
-
expect(@fru.names.count).to eq(1)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should return a fru using method missing' do
|
68
|
-
@fru.names.each do |name|
|
69
|
-
fru = @fru.send(name)
|
70
|
-
expect(fru).to be_an_instance_of(Rubyipmi::Freeipmi::FruData)
|
71
|
-
expect(fru[:name]).to eq(name)
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
File without changes
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe :Sensors do
|
5
|
-
before :all do
|
6
|
-
@path = '/usr/local/bin'
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
allow_message_expectations_on_nil
|
11
|
-
data = nil
|
12
|
-
provider = "freeipmi"
|
13
|
-
user = "ipmiuser"
|
14
|
-
pass = "impipass"
|
15
|
-
host = "ipmihost"
|
16
|
-
# this stub allows us to mock the command that would be used to verify provider installation
|
17
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
18
|
-
|
19
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
20
|
-
@sensors = @conn.sensors
|
21
|
-
File.open("spec/fixtures/#{provider}/sensors.txt",'r') do |file|
|
22
|
-
data = file.read
|
23
|
-
end
|
24
|
-
# this stub allows us to mock the command that is used with this test case
|
25
|
-
allow(@sensors).to receive(:locate_command).with('ipmi-sensors').and_return('/usr/local/bin/ipmi-sensors')
|
26
|
-
|
27
|
-
# these stubs allow us to run the command and return the fixtures
|
28
|
-
allow(@sensors).to receive(:`).and_return(data)
|
29
|
-
allow($?).to receive(:success?).and_return(true)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it "cmd should be ipmi-sensors with six arguments" do
|
34
|
-
@sensors.list
|
35
|
-
verify_freeipmi_command(@sensors, 6, "#{@path}/ipmi-sensors")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "can return a list of sensors" do
|
39
|
-
expect(@sensors.list).not_to be_nil
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return a count of sensors" do
|
43
|
-
expect(@sensors.count).to eq(29)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should return a list of fan names" do
|
47
|
-
expect(@sensors.fanlist.count).to eq(13)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should return a list of temp names' do
|
51
|
-
expect(@sensors.templist.count).to eq(7)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should return a list of sensor names as an array' do
|
55
|
-
expect(@sensors.names).to be_an_instance_of(Array)
|
56
|
-
expect(@sensors.names.count).to eq(29)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should return an empty list if no data exists' do
|
60
|
-
allow(@sensors).to receive(:getsensors).and_return(nil)
|
61
|
-
expect(@sensors.names.count).to eq(0)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should return a sensor using method missing' do
|
65
|
-
@sensors.names.each do |name|
|
66
|
-
sensor = @sensors.send(name)
|
67
|
-
expect(sensor).to be_an_instance_of(Rubyipmi::Freeipmi::Sensor)
|
68
|
-
expect(sensor[:name]).to eq(name)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
#it 'fix should be added to options after error occurs' do
|
73
|
-
# error = nil
|
74
|
-
# File.open("spec/fixtures/freeipmi/errors.txt",'r') do |file|
|
75
|
-
# error = file.read
|
76
|
-
# end
|
77
|
-
# @sensors.stub(:`).and_return(error)
|
78
|
-
# $?.stub(:success?).and_return(false)
|
79
|
-
# @sensors.refresh
|
80
|
-
# after = @sensors.options.fetch('driver-type', false).should_not be_false
|
81
|
-
#end
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe "Bmc" do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
@path = '/usr/local/bin'
|
8
|
-
end
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
allow_message_expectations_on_nil
|
12
|
-
provider = "ipmitool"
|
13
|
-
user = "ipmiuser"
|
14
|
-
pass = "impipass"
|
15
|
-
host = "ipmihost"
|
16
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
17
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
18
|
-
@bmc = @conn.bmc
|
19
|
-
data = nil
|
20
|
-
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
21
|
-
data = file.read
|
22
|
-
end
|
23
|
-
|
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)
|
27
|
-
|
28
|
-
allow(@bmc).to receive(:guid).and_return("guid")
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
it "bmc should not be nil" do
|
33
|
-
expect(@bmc).not_to be nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "lan should not be nil" do
|
37
|
-
expect(@bmc.lan).not_to be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "guid should not be nil" do
|
41
|
-
expect(@bmc.guid).not_to be_nil
|
42
|
-
end
|
43
|
-
|
44
|
-
it "info should not be nil" do
|
45
|
-
expect(@bmc.info).not_to be_nil
|
46
|
-
end
|
47
|
-
|
48
|
-
it "info should parse as expected" do
|
49
|
-
expect(@bmc.info).to eq(RETRIEVE)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
RETRIEVE = {
|
55
|
-
'Device ID' => '17',
|
56
|
-
'Device Revision' => '1',
|
57
|
-
'Firmware Revision' => '2.9',
|
58
|
-
'IPMI Version' => '2.0',
|
59
|
-
'Manufacturer ID' => '11',
|
60
|
-
'Manufacturer Name' => 'Hewlett-Packard',
|
61
|
-
'Product ID' => '8192 (0x2000)',
|
62
|
-
'Product Name' => 'Unknown (0x2000)',
|
63
|
-
'Device Available' => 'yes',
|
64
|
-
'Provides Device SDRs' => 'yes',
|
65
|
-
'Additional Device Support' => [
|
66
|
-
'Sensor Device',
|
67
|
-
'SDR Repository Device',
|
68
|
-
'SEL Device',
|
69
|
-
'FRU Inventory Device'
|
70
|
-
],
|
71
|
-
'Aux Firmware Rev Info' => [
|
72
|
-
'0x00',
|
73
|
-
'0x00',
|
74
|
-
'0x00',
|
75
|
-
'0x30'
|
76
|
-
]
|
77
|
-
}
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe :Connection do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
@path = '/usr/local/bin'
|
7
|
-
@provider = "ipmitool"
|
8
|
-
@user = "ipmiuser"
|
9
|
-
@pass = "impipass"
|
10
|
-
@host = "ipmihost"
|
11
|
-
end
|
12
|
-
|
13
|
-
before :each do
|
14
|
-
|
15
|
-
allow(Rubyipmi).to receive(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
16
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
it "connection should not be nil" do
|
21
|
-
expect(@conn).not_to be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "fru should not be nil" do
|
25
|
-
expect(@conn.fru).not_to be_nil
|
26
|
-
end
|
27
|
-
|
28
|
-
it "provider should not be nil" do
|
29
|
-
expect(@conn.provider).not_to be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "provider should be ipmitool" do
|
33
|
-
expect(@conn.provider).to eq("ipmitool")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "bmc should not be nil" do
|
37
|
-
expect(@conn.bmc).not_to be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "sensors should not be nil" do
|
41
|
-
expect(@conn.sensors).not_to be_nil
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
it "chassis should not be nill" do
|
46
|
-
expect(@conn.chassis).not_to be_nil
|
47
|
-
end
|
48
|
-
|
49
|
-
it "provider should return ipmitool" do
|
50
|
-
expect(@conn.provider).to eq("ipmitool")
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'object should have driver set to auto if not specified' do
|
54
|
-
expect(@conn.options['I']).to eq 'lanplus'
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'object should have driver set to auto if not specified' do
|
59
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
60
|
-
expect(@conn.options.has_key?('I')).to eq false
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should raise exception if invalid driver type' do
|
64
|
-
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'foo'})}.to raise_error(RuntimeError)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'object should have priv type set to ADMINISTRATOR if not specified' do
|
68
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
69
|
-
expect(@conn.options.has_key?('L')).to eq false
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'object should have priv type set to USER ' do
|
73
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
|
74
|
-
expect(@conn.options.fetch('L')).to eq('USER')
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should raise exception if invalid privilege type' do
|
78
|
-
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'BLAH',:debug => true, :driver => 'auto'})}.to raise_error(RuntimeError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'object should have driver set to lanplus' do
|
82
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
|
83
|
-
expect(@conn.options['I']).to eq('lanplus')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'object should have driver set to lanplus' do
|
87
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
|
88
|
-
expect(@conn.options['I']).to eq('lan')
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'object should have driver set to open' do
|
92
|
-
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
|
93
|
-
expect(@conn.options['I']).to eq('open')
|
94
|
-
end
|
95
|
-
describe 'test' do
|
96
|
-
it 'should retrun boolean on test connection when result is not a hash' do
|
97
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
98
|
-
bmc = double()
|
99
|
-
allow(bmc).to receive(:info).and_return('')
|
100
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
101
|
-
expect(conn.connection_works?).to eq false
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should retrun boolean on test connection when result is a hash' do
|
105
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
106
|
-
bmc = double()
|
107
|
-
allow(bmc).to receive(:info).and_return({:test => true})
|
108
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
109
|
-
expect(conn.connection_works?).to eq true
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should retrun boolean on test connection when nil' do
|
113
|
-
conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
114
|
-
bmc = double()
|
115
|
-
allow(bmc).to receive(:info).and_return(nil)
|
116
|
-
allow(conn).to receive(:bmc).and_return(bmc)
|
117
|
-
expect(conn.connection_works?).to eq false
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'rubyipmi/ipmitool/errorcodes'
|
4
|
-
|
5
|
-
describe "Errorcodes" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
it 'should return the length of fix hash' do
|
10
|
-
expect(Rubyipmi::Ipmitool::ErrorCodes.length).to be > 1
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should return a hash of codes' do
|
14
|
-
expect(Rubyipmi::Ipmitool::ErrorCodes.code).to be_an_instance_of Hash
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should return a fix if code is found' do
|
19
|
-
code = 'Authentication type NONE not supported'
|
20
|
-
expect(Rubyipmi::Ipmitool::ErrorCodes.search(code)).to eq({"I"=>"lanplus"})
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should throw and error if no fix is found' do
|
24
|
-
code = 'Crap Shoot'
|
25
|
-
expect {Rubyipmi::Ipmitool::ErrorCodes.search(code)}.to raise_error
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should throw and error when a bad code is given' do
|
29
|
-
code = nil
|
30
|
-
expect {Rubyipmi::Ipmitool::ErrorCodes.search(code)}.to raise_error
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|