rubyipmi 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -8
- data/README.md +92 -27
- data/Rakefile +1 -6
- data/VERSION +1 -1
- data/lib/rubyipmi.rb +69 -30
- data/lib/rubyipmi/commands/basecommand.rb +16 -18
- data/lib/rubyipmi/freeipmi/commands/basecommand.rb +2 -4
- data/lib/rubyipmi/freeipmi/commands/bmc.rb +7 -0
- data/lib/rubyipmi/freeipmi/commands/bmcconfig.rb +10 -0
- data/lib/rubyipmi/freeipmi/commands/bmcdevice.rb +1 -0
- data/lib/rubyipmi/freeipmi/commands/bmcinfo.rb +0 -3
- data/lib/rubyipmi/freeipmi/commands/chassis.rb +1 -0
- data/lib/rubyipmi/freeipmi/commands/chassisconfig.rb +0 -2
- data/lib/rubyipmi/freeipmi/commands/fru.rb +0 -1
- data/lib/rubyipmi/freeipmi/commands/lan.rb +22 -23
- data/lib/rubyipmi/freeipmi/commands/sensors.rb +8 -7
- data/lib/rubyipmi/freeipmi/connection.rb +14 -19
- data/lib/rubyipmi/freeipmi/errorcodes.rb +0 -1
- data/lib/rubyipmi/ipmitool/commands/basecommand.rb +0 -3
- data/lib/rubyipmi/ipmitool/commands/bmc.rb +8 -0
- data/lib/rubyipmi/ipmitool/commands/chassis.rb +1 -0
- data/lib/rubyipmi/ipmitool/commands/fru.rb +0 -7
- data/lib/rubyipmi/ipmitool/connection.rb +12 -13
- data/lib/rubyipmi/ipmitool/errorcodes.rb +2 -1
- data/rubyipmi.gemspec +21 -14
- data/spec/integration/bmc_spec.rb +9 -10
- data/spec/integration/chassis_config_spec.rb +6 -8
- data/spec/integration/chassis_spec.rb +3 -3
- data/spec/integration/connection_spec.rb +16 -15
- data/spec/integration/fru_spec.rb +6 -7
- data/spec/integration/lan_spec.rb +21 -34
- data/spec/integration/power_spec.rb +5 -5
- data/spec/integration/rubyipmi_spec.rb +63 -9
- data/spec/integration/sensor_spec.rb +7 -8
- data/spec/spec_helper.rb +10 -7
- data/spec/unit/freeipmi/bmc-info_spec.rb +5 -6
- data/spec/unit/freeipmi/bmc_spec.rb +8 -9
- data/spec/unit/freeipmi/connection_spec.rb +41 -23
- data/spec/unit/freeipmi/errorcodes_spec.rb +4 -10
- data/spec/unit/freeipmi/fru_spec.rb +15 -16
- data/spec/unit/freeipmi/sensors_spec.rb +17 -15
- data/spec/unit/ipmitool/bmc_spec.rb +11 -12
- data/spec/unit/ipmitool/connection_spec.rb +43 -21
- data/spec/unit/ipmitool/errorcodes_spec.rb +5 -4
- data/spec/unit/ipmitool/fru_spec.rb +15 -15
- data/spec/unit/ipmitool/lan_spec.rb +16 -15
- data/spec/unit/ipmitool/sensors_spec.rb +16 -15
- data/spec/unit/rubyipmi_spec.rb +6 -6
- metadata +64 -24
- data/README.rdoc +0 -18
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Power" do
|
4
4
|
|
@@ -13,13 +13,13 @@ describe "Power" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "test to turn power on" do
|
16
|
-
@conn.chassis.power.on.
|
16
|
+
expect(@conn.chassis.power.on).to be_truthy
|
17
17
|
sleep(2)
|
18
|
-
@conn.chassis.power.status.
|
18
|
+
expect(@conn.chassis.power.status).to eq('on')
|
19
19
|
end
|
20
20
|
|
21
21
|
it "test power status" do
|
22
|
-
@conn.chassis.power.status.
|
22
|
+
expect(@conn.chassis.power.status).to eq('off')
|
23
23
|
|
24
24
|
end
|
25
25
|
|
@@ -34,7 +34,7 @@ describe "Power" do
|
|
34
34
|
max_count = max_count - 1
|
35
35
|
end
|
36
36
|
end
|
37
|
-
@conn.chassis.power.off
|
37
|
+
expect(@conn.chassis.power.off?).to be true
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'logger'
|
2
4
|
|
3
5
|
describe "rubyipmi" do
|
4
6
|
before :each do
|
@@ -11,22 +13,22 @@ describe "rubyipmi" do
|
|
11
13
|
end
|
12
14
|
it "creates a connection object" do
|
13
15
|
conn = Rubyipmi.connect(@user, @pass, @host, @provider)
|
14
|
-
conn.
|
16
|
+
expect(conn).to be_truthy
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should test if a provider is present" do
|
18
20
|
value = Rubyipmi.is_provider_installed?("ipmitool")
|
19
21
|
value2 = Rubyipmi.is_provider_installed?("freeipmi")
|
20
|
-
(value|value2).
|
22
|
+
expect((value|value2)).to eq true
|
21
23
|
|
22
24
|
end
|
23
25
|
|
24
26
|
it "should create a connection object if freeipmi is present" do
|
25
27
|
begin
|
26
28
|
conn = Rubyipmi.connect(@user, @pass, @host, "freeipmi")
|
27
|
-
conn.kind_of?(Rubyipmi::Freeipmi::Connection).
|
29
|
+
expect(conn.kind_of?(Rubyipmi::Freeipmi::Connection)).to eq true
|
28
30
|
rescue Exception => e
|
29
|
-
e.message.match(/freeipmi\ is\ not\ installed/).
|
31
|
+
expect(e.message.match(/freeipmi\ is\ not\ installed/)).to eq true
|
30
32
|
puts "#{e.message}"
|
31
33
|
end
|
32
34
|
end
|
@@ -35,26 +37,78 @@ describe "rubyipmi" do
|
|
35
37
|
begin
|
36
38
|
conn = Rubyipmi.connect(@user, @pass, @host, "ipmitool")
|
37
39
|
rescue Exception => e
|
38
|
-
e.message.match(/ipmitool\ is\ not\ installed/)
|
40
|
+
expect(e.message).to match(/ipmitool\ is\ not\ installed/)
|
39
41
|
puts "#{e.message}"
|
40
42
|
return true
|
41
43
|
end
|
42
|
-
conn.kind_of?(Rubyipmi::Ipmitool::Connection).
|
44
|
+
expect(conn.kind_of?(Rubyipmi::Ipmitool::Connection)).to eq true
|
43
45
|
end
|
44
46
|
|
45
47
|
it "should not create a connection object if a provider is not present" do
|
46
48
|
begin
|
47
49
|
conn = Rubyipmi.connect(@user, @pass, @host, "bogus")
|
48
50
|
rescue Exception => e
|
49
|
-
e.message.match(/Invalid/)
|
51
|
+
expect(e.message).to match(/Invalid/)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
55
|
it "check to find any available installed providers" do
|
54
|
-
Rubyipmi.providers_installed?.length.
|
56
|
+
expect(Rubyipmi.providers_installed?.length).to be > 0
|
55
57
|
end
|
56
58
|
|
59
|
+
it 'can get diag info' do
|
60
|
+
# must have both freeipmi and ipmitool for this to pass
|
61
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
62
|
+
expect(File.exists?('/tmp/rubyipmi_diag_data.txt')).to be true
|
63
|
+
FileUtils.rm('/tmp/rubyipmi_diag_data.txt')
|
64
|
+
end
|
65
|
+
|
66
|
+
describe :logger do
|
67
|
+
before :each do
|
68
|
+
FileUtils.rm_f('/tmp/rubyipmi.log')
|
69
|
+
Rubyipmi.log_level = nil
|
70
|
+
Rubyipmi.logger = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should only create an info log level' do
|
74
|
+
Rubyipmi.log_level = Logger::INFO
|
75
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
76
|
+
expect(File.exists?('/tmp/rubyipmi.log')).to be true
|
77
|
+
size = File.open('/tmp/rubyipmi.log', 'r') {|f| f.read.length}
|
78
|
+
expect(size).to be_within(60).of(100)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should create a log with debug level' do
|
82
|
+
Rubyipmi.log_level = Logger::DEBUG
|
83
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
84
|
+
expect(File.exists?('/tmp/rubyipmi.log')).to be true
|
85
|
+
size = File.open('/tmp/rubyipmi.log', 'r') {|f| f.read.length}
|
86
|
+
expect(size).to be > 100
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should use custom logger' do
|
90
|
+
FileUtils.rm_f('/tmp/rubyipmi_custom.log')
|
91
|
+
logger = Logger.new('/tmp/rubyipmi_custom.log')
|
92
|
+
logger.level = Logger::DEBUG
|
93
|
+
Rubyipmi.logger = logger
|
94
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
95
|
+
expect(File.exists?('/tmp/rubyipmi_custom.log')).to be true
|
96
|
+
size = File.open('/tmp/rubyipmi_custom.log', 'r') {|f| f.read.length}
|
97
|
+
expect(size).to be > 100
|
98
|
+
FileUtils.rm_f('/tmp/rubyipmi_custom.log')
|
99
|
+
end
|
57
100
|
|
101
|
+
it 'should not create a log file when log level is nil' do
|
102
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
103
|
+
expect(Rubyipmi.logger.instance_of?(NullLogger)).to be true
|
104
|
+
expect(File.exists?('/tmp/rubyipmi.log')).to be false
|
105
|
+
end
|
58
106
|
|
107
|
+
it 'should not create a log file when logger is set to nil and log_level is nil' do
|
108
|
+
Rubyipmi.get_diag(@user,@pass,@host)
|
109
|
+
expect(Rubyipmi.logger.instance_of?(NullLogger)).to be true
|
110
|
+
expect(File.exists?('/tmp/rubyipmi.log')).to be false
|
111
|
+
end
|
112
|
+
end
|
59
113
|
end
|
60
114
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'spec_helper'
|
3
2
|
describe "Sensors" do
|
4
3
|
|
5
4
|
attr_accessor :provider
|
@@ -13,30 +12,30 @@ describe "Sensors" do
|
|
13
12
|
end
|
14
13
|
|
15
14
|
it "test get all sensors" do
|
16
|
-
@conn.sensors.list.count.
|
15
|
+
expect(@conn.sensors.list.count).to be > 1
|
17
16
|
end
|
18
17
|
|
19
18
|
it "test should refresh data" do
|
20
19
|
old = @conn.sensors.list
|
21
20
|
@conn.sensors.refresh
|
22
21
|
new = @conn.sensors.list
|
23
|
-
old.
|
22
|
+
expect(old).not_to equal(new)
|
24
23
|
end
|
25
24
|
|
26
25
|
it "test should return count greater than 1" do
|
27
|
-
@conn.sensors.count.
|
26
|
+
expect(@conn.sensors.count).to be > 1
|
28
27
|
end
|
29
28
|
|
30
29
|
it "test should return names" do
|
31
|
-
@conn.sensors.names.count.
|
30
|
+
expect(@conn.sensors.names.count).to be > 1
|
32
31
|
end
|
33
32
|
|
34
33
|
it "test should return list of fans" do
|
35
|
-
@conn.sensors.fanlist.count.
|
34
|
+
expect(@conn.sensors.fanlist.count).to be > 1
|
36
35
|
end
|
37
36
|
|
38
37
|
it "test should return list of temps" do
|
39
|
-
@conn.sensors.templist.count.
|
38
|
+
expect(@conn.sensors.templist.count).to be > 1
|
40
39
|
end
|
41
40
|
|
42
41
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
4
|
require 'rubyipmi'
|
5
|
-
|
5
|
+
require 'coveralls'
|
6
|
+
Coveralls.wear!
|
6
7
|
# Requires supporting files with custom matchers and macros, etc,
|
7
8
|
# in ./support/ and its subdirectories.
|
8
9
|
|
@@ -17,28 +18,30 @@ end
|
|
17
18
|
def verify_freeipmi_command(cmdobj, exp_args_count, expcmd)
|
18
19
|
actual = cmdobj.lastcall
|
19
20
|
actual.scan(/(^#{Regexp.escape(expcmd)})/) do |cmd_match|
|
20
|
-
cmd_match.first.
|
21
|
+
expect(cmd_match.first).to eq(expcmd)
|
21
22
|
end
|
22
23
|
args_match = actual.scan(/(\-{2}[\w-]*=?[-\w\/]*)/)
|
23
24
|
# not sure how to exactly test for arguments since they could vary, so we will need to use count for now
|
24
25
|
#args_match.should =~ exp_args
|
25
|
-
args_match.count.
|
26
|
+
expect(args_match.count).to eq(exp_args_count)
|
26
27
|
end
|
27
28
|
|
28
29
|
|
29
30
|
def verify_ipmitool_command(cmdobj, exp_args_count, expcmd, required_args)
|
30
31
|
actual = cmdobj.lastcall
|
31
32
|
actual.scan(/(^#{Regexp.escape(expcmd)})/) do |cmd_match|
|
32
|
-
cmd_match.first.
|
33
|
+
expect(cmd_match.first).to eq(expcmd)
|
33
34
|
end
|
34
35
|
args_match = actual.scan(/(-\w\s[\w\d\S]*)/)
|
35
|
-
actual.include?(required_args).
|
36
|
+
expect(actual.include?(required_args)).to eq true
|
36
37
|
# not sure how to exactly test for arguments since they could vary, so we will need to use count for now
|
37
38
|
#args_match.should =~ exp_args
|
38
|
-
args_match.count.
|
39
|
+
expect(args_match.count).to eq(exp_args_count)
|
39
40
|
end
|
40
41
|
|
41
42
|
|
42
43
|
RSpec.configure do |config|
|
43
|
-
|
44
|
+
config.expect_with :rspec do |c|
|
45
|
+
c.syntax = [:expect]
|
46
|
+
end
|
44
47
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
|
5
4
|
describe "Bmc" do
|
@@ -13,7 +12,7 @@ describe "Bmc" do
|
|
13
12
|
user = "ipmiuser"
|
14
13
|
pass = "impipass"
|
15
14
|
host = "ipmihost"
|
16
|
-
Rubyipmi.
|
15
|
+
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
16
|
|
18
17
|
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
19
18
|
@bmcinfo = @conn.bmc.information
|
@@ -21,9 +20,9 @@ describe "Bmc" do
|
|
21
20
|
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
22
21
|
data = file.read
|
23
22
|
end
|
24
|
-
@bmcinfo.
|
25
|
-
@bmcinfo.
|
26
|
-
|
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)
|
27
26
|
end
|
28
27
|
|
29
28
|
it "cmd should be bmc-info with correct number of arguments" do
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
|
5
4
|
describe "Bmc" do
|
@@ -13,7 +12,7 @@ describe "Bmc" do
|
|
13
12
|
user = "ipmiuser"
|
14
13
|
pass = "impipass"
|
15
14
|
host = "ipmihost"
|
16
|
-
Rubyipmi.
|
15
|
+
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
16
|
|
18
17
|
@conn = Rubyipmi.connect(user, pass, host, provider,{:debug => true})
|
19
18
|
@bmc = @conn.bmc
|
@@ -21,24 +20,24 @@ describe "Bmc" do
|
|
21
20
|
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
22
21
|
data = file.read
|
23
22
|
end
|
24
|
-
@bmc.
|
25
|
-
@bmc.
|
23
|
+
allow(@bmc).to receive(:guid).and_return("guid")
|
24
|
+
allow(@bmc).to receive(:info).and_return("info")
|
26
25
|
end
|
27
26
|
|
28
27
|
it "bmc should not be nil" do
|
29
|
-
@bmc.
|
28
|
+
expect(@bmc).not_to be nil
|
30
29
|
end
|
31
30
|
|
32
31
|
it "lan should not be nil" do
|
33
|
-
@bmc.lan.
|
32
|
+
expect(@bmc.lan).not_to be_nil
|
34
33
|
end
|
35
34
|
|
36
35
|
it "guid should not be nil" do
|
37
|
-
@bmc.guid.
|
36
|
+
expect(@bmc.guid).not_to be_nil
|
38
37
|
end
|
39
38
|
|
40
39
|
it "info should not be nill" do
|
41
|
-
@bmc.info.
|
40
|
+
expect(@bmc.info).not_to be_nil
|
42
41
|
end
|
43
42
|
|
44
43
|
end
|
@@ -1,8 +1,5 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
|
-
|
6
3
|
describe "Bmc" do
|
7
4
|
|
8
5
|
before :all do
|
@@ -16,7 +13,7 @@ describe "Bmc" do
|
|
16
13
|
before :each do
|
17
14
|
|
18
15
|
|
19
|
-
Rubyipmi.
|
16
|
+
allow(Rubyipmi).to receive(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
20
17
|
|
21
18
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
|
22
19
|
|
@@ -24,56 +21,52 @@ describe "Bmc" do
|
|
24
21
|
end
|
25
22
|
|
26
23
|
it "connection should not be nil" do
|
27
|
-
@conn.
|
24
|
+
expect(@conn).not_to be_nil
|
28
25
|
end
|
29
26
|
|
30
27
|
it "fru should not be nil" do
|
31
|
-
@conn.fru.
|
28
|
+
expect(@conn.fru).not_to be_nil
|
32
29
|
end
|
33
30
|
|
34
31
|
it "provider should not be nil" do
|
35
|
-
@conn.provider.
|
32
|
+
expect(@conn.provider).not_to be_nil
|
36
33
|
end
|
37
34
|
|
38
35
|
it "provider should be freeipmi" do
|
39
|
-
@conn.provider.
|
36
|
+
expect(@conn.provider).to eq("freeipmi")
|
40
37
|
end
|
41
38
|
|
42
39
|
it "bmc should not be nil" do
|
43
|
-
@conn.bmc.
|
40
|
+
expect(@conn.bmc).not_to be_nil
|
44
41
|
end
|
45
42
|
|
46
43
|
it "sensors should not be nil" do
|
47
|
-
@conn.sensors.
|
44
|
+
expect(@conn.sensors).not_to be_nil
|
48
45
|
|
49
46
|
end
|
50
47
|
|
51
48
|
it "chassis should not be nill" do
|
52
|
-
@conn.chassis.
|
49
|
+
expect(@conn.chassis).not_to be_nil
|
53
50
|
|
54
51
|
end
|
55
52
|
|
56
|
-
it 'object should have debug set to true' do
|
57
|
-
@conn.debug.should be_true
|
58
|
-
end
|
59
|
-
|
60
53
|
it 'object should have driver set to auto if not specified' do
|
61
|
-
@conn.options.has_key?('driver-type').
|
54
|
+
expect(@conn.options.has_key?('driver-type')).to eq false
|
62
55
|
end
|
63
56
|
|
64
57
|
it 'object should have driver set to auto if not specified' do
|
65
58
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
66
|
-
@conn.options.has_key?('driver-type').
|
59
|
+
expect(@conn.options.has_key?('driver-type')).to eq false
|
67
60
|
end
|
68
61
|
|
69
62
|
it 'object should have priv type set to ADMINISTRATOR if not specified' do
|
70
63
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
71
|
-
@conn.options.has_key?('privilege-level').
|
64
|
+
expect(@conn.options.has_key?('privilege-level')).to eq false
|
72
65
|
end
|
73
66
|
|
74
67
|
it 'object should have priv type set to USER ' do
|
75
68
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
|
76
|
-
@conn.options.fetch('privilege-level').
|
69
|
+
expect(@conn.options.fetch('privilege-level')).to eq('USER')
|
77
70
|
end
|
78
71
|
|
79
72
|
it 'should raise exception if invalid privilege type' do
|
@@ -86,17 +79,42 @@ describe "Bmc" do
|
|
86
79
|
|
87
80
|
it 'object should have driver set to lan_2_0' do
|
88
81
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
|
89
|
-
@conn.options['driver-type'].
|
82
|
+
expect(@conn.options['driver-type']).to eq('LAN_2_0')
|
90
83
|
end
|
91
84
|
|
92
85
|
it 'object should have driver set to lan' do
|
93
86
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
|
94
|
-
@conn.options['driver-type'].
|
87
|
+
expect(@conn.options['driver-type']).to eq('LAN')
|
95
88
|
end
|
96
89
|
|
97
90
|
it 'object should have driver set to openipmi' do
|
98
91
|
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
|
99
|
-
@conn.options['driver-type'].
|
92
|
+
expect(@conn.options['driver-type']).to eq('OPENIPMI')
|
93
|
+
end
|
94
|
+
|
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
|
100
119
|
end
|
101
|
-
|
102
120
|
end
|
@@ -1,22 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
#require 'rubyipmi/Freeipmi/errorcodes'
|
3
3
|
|
4
4
|
describe "Errorcodes" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
5
|
it 'should return the length of fix hash' do
|
9
|
-
Rubyipmi::Freeipmi::ErrorCodes.length.
|
6
|
+
expect(Rubyipmi::Freeipmi::ErrorCodes.length).to be >= 1
|
10
7
|
end
|
11
8
|
|
12
9
|
it 'should return a hash of codes' do
|
13
|
-
Rubyipmi::Freeipmi::ErrorCodes.code.
|
10
|
+
expect(Rubyipmi::Freeipmi::ErrorCodes.code).to be_an_instance_of Hash
|
14
11
|
|
15
12
|
end
|
16
13
|
|
17
14
|
it 'should return a fix if code is found' do
|
18
15
|
code = 'authentication type unavailable for attempted privilege level'
|
19
|
-
Rubyipmi::Freeipmi::ErrorCodes.search(code).
|
16
|
+
expect(Rubyipmi::Freeipmi::ErrorCodes.search(code)).to eq({"driver-type" => "LAN_2_0"})
|
20
17
|
end
|
21
18
|
|
22
19
|
it 'should throw and error if no fix is found' do
|
@@ -28,7 +25,4 @@ describe "Errorcodes" do
|
|
28
25
|
code = nil
|
29
26
|
expect {Rubyipmi::Freeipmi::ErrorCodes.search(code)}.to raise_error
|
30
27
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
28
|
end
|