rubyipmi 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/Gemfile +1 -1
- data/LICENSE.txt +460 -13
- data/README.md +40 -20
- data/RELEASE_NOTES.md +4 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rubyipmi/freeipmi/connection.rb +19 -5
- data/lib/rubyipmi/ipmitool/commands/power.rb +3 -3
- data/lib/rubyipmi/ipmitool/connection.rb +16 -8
- data/lib/rubyipmi.rb +133 -82
- data/rubyipmi.gemspec +6 -7
- data/spec/unit/freeipmi/bmc-info_spec.rb +5 -8
- data/spec/unit/freeipmi/bmc_spec.rb +1 -1
- data/spec/unit/freeipmi/connection_spec.rb +51 -5
- data/spec/unit/freeipmi/fru_spec.rb +1 -1
- data/spec/unit/freeipmi/sensors_spec.rb +1 -1
- data/spec/unit/ipmitool/bmc_spec.rb +1 -1
- data/spec/unit/ipmitool/connection_spec.rb +46 -5
- data/spec/unit/ipmitool/fru_spec.rb +1 -1
- data/spec/unit/ipmitool/lan_spec.rb +1 -1
- data/spec/unit/ipmitool/sensors_spec.rb +1 -1
- metadata +12 -26
@@ -11,10 +11,11 @@ module Rubyipmi
|
|
11
11
|
|
12
12
|
class Connection
|
13
13
|
|
14
|
-
attr_accessor :options
|
14
|
+
attr_accessor :options, :debug
|
15
15
|
|
16
16
|
|
17
|
-
def initialize(user, pass, host,
|
17
|
+
def initialize(user, pass, host, opts)
|
18
|
+
@debug = opts[:debug]
|
18
19
|
@options = Rubyipmi::ObservableHash.new
|
19
20
|
raise("Must provide a host to connect to") unless host
|
20
21
|
@options["hostname"] = host
|
@@ -22,12 +23,24 @@ module Rubyipmi
|
|
22
23
|
# So they are not required
|
23
24
|
@options["username"] = user if user
|
24
25
|
@options["password"] = pass if pass
|
25
|
-
|
26
|
-
#
|
26
|
+
if opts.has_key?(:privilege)
|
27
|
+
@options["privilege-level"] = opts[:privilege] # privilege type
|
28
|
+
end
|
29
|
+
# Note: rubyipmi should auto detect which driver to use so its unnecessary to specify the driver unless
|
30
|
+
# the user really wants to.
|
31
|
+
@options['driver-type'] = drivers_map[opts[:driver]] unless drivers_map[opts[:driver]].nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
def drivers_map
|
35
|
+
{
|
36
|
+
'lan15' => 'LAN',
|
37
|
+
'lan20' => 'LAN_2_0',
|
38
|
+
'open' => 'OPENIPMI'
|
39
|
+
}
|
27
40
|
end
|
28
41
|
|
29
42
|
def provider
|
30
|
-
|
43
|
+
'freeipmi'
|
31
44
|
end
|
32
45
|
|
33
46
|
def fru
|
@@ -63,3 +76,4 @@ module Rubyipmi
|
|
63
76
|
end
|
64
77
|
end
|
65
78
|
end
|
79
|
+
|
@@ -13,11 +13,10 @@ module Rubyipmi
|
|
13
13
|
class Connection
|
14
14
|
|
15
15
|
attr_accessor :options, :debug
|
16
|
-
attr_reader :debug
|
17
16
|
|
18
17
|
|
19
|
-
def initialize(user, pass, host,
|
20
|
-
@debug =
|
18
|
+
def initialize(user, pass, host, opts)
|
19
|
+
@debug = opts[:debug]
|
21
20
|
@options = Rubyipmi::ObservableHash.new
|
22
21
|
raise("Must provide a host to connect to") unless host
|
23
22
|
@options["H"] = host
|
@@ -25,11 +24,20 @@ module Rubyipmi
|
|
25
24
|
# So they are not required
|
26
25
|
@options["U"] = user if user
|
27
26
|
@options["P"] = pass if pass
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
if opts.has_key?(:privilege)
|
28
|
+
@options["L"] = opts[:privilege]
|
29
|
+
end
|
30
|
+
# Note: rubyipmi should auto detect which driver to use so its unnecessary to specify the driver unless
|
31
|
+
# the user really wants to.
|
32
|
+
@options['I'] = drivers_map[opts[:driver]] unless drivers_map[opts[:driver]].nil?
|
33
|
+
end
|
31
34
|
|
32
|
-
|
35
|
+
def drivers_map
|
36
|
+
{
|
37
|
+
'lan15' => 'lan',
|
38
|
+
'lan20' => 'lanplus',
|
39
|
+
'open' => 'open'
|
40
|
+
}
|
33
41
|
end
|
34
42
|
|
35
43
|
def fru
|
@@ -37,7 +45,7 @@ module Rubyipmi
|
|
37
45
|
end
|
38
46
|
|
39
47
|
def provider
|
40
|
-
|
48
|
+
'ipmitool'
|
41
49
|
end
|
42
50
|
|
43
51
|
def bmc
|
data/lib/rubyipmi.rb
CHANGED
@@ -1,113 +1,164 @@
|
|
1
|
+
# Copyright (C) 2014 Corey Osman
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
16
|
+
# USA
|
17
|
+
#
|
18
|
+
|
19
|
+
|
1
20
|
require 'rubyipmi/ipmitool/connection'
|
2
21
|
require 'rubyipmi/freeipmi/connection'
|
3
22
|
|
4
23
|
|
5
24
|
module Rubyipmi
|
25
|
+
PRIV_TYPES = ['CALLBACK', 'USER', 'OPERATOR', 'ADMINISTRATOR']
|
6
26
|
|
27
|
+
def self.valid_drivers
|
28
|
+
['auto', "lan15", "lan20", "open"]
|
29
|
+
end
|
7
30
|
|
8
31
|
# The connect method will create a connection object based the provider type passed in
|
9
32
|
# If provider is left blank the function will use the first available provider
|
10
33
|
|
11
|
-
|
12
|
-
|
13
|
-
# use this variable to reduce cmd calls
|
14
|
-
installed = false
|
15
|
-
|
16
|
-
# use the first available provider
|
17
|
-
if provider == "any"
|
18
|
-
if is_provider_installed?("freeipmi")
|
19
|
-
provider = "freeipmi"
|
20
|
-
installed = true
|
21
|
-
elsif is_provider_installed?("ipmitool")
|
22
|
-
provider = "ipmitool"
|
23
|
-
installed = true
|
24
|
-
else
|
25
|
-
raise "No IPMI provider is installed, please install freeipmi or ipmitool"
|
26
|
-
end
|
27
|
-
end
|
34
|
+
def self.connect(user, pass, host, provider='any', opts={:driver => 'auto',
|
35
|
+
:timeout => 'default', :debug => false})
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
if provider == "freeipmi"
|
32
|
-
@conn = Rubyipmi::Freeipmi::Connection.new(user, pass, host, debug)
|
33
|
-
elsif provider == "ipmitool"
|
34
|
-
@conn = Rubyipmi::Ipmitool::Connection.new(user,pass,host, debug)
|
35
|
-
else
|
36
|
-
raise "Incorrect provider given, must use freeipmi or ipmitool"
|
37
|
-
end
|
38
|
-
else
|
39
|
-
# Can't find the provider command line tool, maybe try other provider?
|
40
|
-
raise "The IPMI provider: #{provider} is not installed"
|
37
|
+
# use this variable to reduce cmd calls
|
38
|
+
installed = false
|
41
39
|
|
42
|
-
|
40
|
+
if provider.is_a?(Hash)
|
41
|
+
opts = provider
|
42
|
+
provider = 'any'
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# Verify options just in case user passed in a incomplete hash
|
46
|
+
opts[:driver] ||= 'auto'
|
47
|
+
opts[:timeout] ||= 'default'
|
48
|
+
opts[:debug] = false if opts[:debug] != true
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if not $?.success?
|
54
|
-
location = nil
|
50
|
+
if ! opts[:privilege].nil?
|
51
|
+
if ! supported_privilege_type?(opts[:privilege])
|
52
|
+
raise "Invalid privilege type :#{opts[:privilege]}, must be one of: #{PRIV_TYPES.join("\n")}"
|
55
53
|
end
|
56
|
-
return location
|
57
54
|
end
|
58
55
|
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
56
|
+
# use the first available provider
|
57
|
+
if provider == 'any'
|
58
|
+
if is_provider_installed?("freeipmi")
|
59
|
+
provider = "freeipmi"
|
60
|
+
installed = true
|
61
|
+
elsif is_provider_installed?("ipmitool")
|
62
|
+
provider = "ipmitool"
|
63
|
+
installed = true
|
64
|
+
else
|
65
|
+
raise "No IPMI provider is installed, please install freeipmi or ipmitool"
|
68
66
|
end
|
69
|
-
# return false if command was not found
|
70
|
-
return ! cmdpath.nil?
|
71
67
|
end
|
72
68
|
|
73
|
-
|
74
|
-
|
69
|
+
# Support multiple drivers
|
70
|
+
# Note: these are just generic names of drivers that need to be specified for each provider
|
71
|
+
unless valid_drivers.include?(opts[:driver])
|
72
|
+
raise "You must specify a valid driver: #{valid_drivers.join(',')}"
|
75
73
|
end
|
76
74
|
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
# If the provider is available create a connection object
|
76
|
+
if installed or is_provider_installed?(provider)
|
77
|
+
if provider == "freeipmi"
|
78
|
+
@conn = Rubyipmi::Freeipmi::Connection.new(user, pass, host, opts)
|
79
|
+
elsif provider == "ipmitool"
|
80
|
+
@conn = Rubyipmi::Ipmitool::Connection.new(user,pass,host, opts)
|
81
|
+
else
|
82
|
+
raise "Incorrect provider given, must use freeipmi or ipmitool"
|
83
|
+
end
|
84
|
+
else
|
85
|
+
# Can't find the provider command line tool, maybe try other provider?
|
86
|
+
raise "The IPMI provider: #{provider} is not installed"
|
81
87
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# returns boolean true if privilege type is valid
|
92
|
+
def self.supported_privilege_type?(type)
|
93
|
+
PRIV_TYPES.include?(type)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.connection
|
97
|
+
return @conn if @conn
|
98
|
+
raise "No Connection available, please use the connect method"
|
99
|
+
end
|
100
|
+
|
101
|
+
# method used to find the command which also makes it easier to mock with
|
102
|
+
def self.locate_command(commandname)
|
103
|
+
location = `which #{commandname}`.strip
|
104
|
+
if not $?.success?
|
105
|
+
location = nil
|
106
|
+
end
|
107
|
+
return location
|
108
|
+
end
|
109
|
+
|
110
|
+
# Return true or false if the provider is available
|
111
|
+
def self.is_provider_installed?(provider)
|
112
|
+
case provider
|
113
|
+
when "freeipmi"
|
114
|
+
cmdpath = locate_command('ipmipower')
|
115
|
+
when "ipmitool"
|
116
|
+
cmdpath = locate_command('ipmitool')
|
117
|
+
else
|
118
|
+
raise "Invalid BMC provider type"
|
119
|
+
end
|
120
|
+
# return false if command was not found
|
121
|
+
return ! cmdpath.nil?
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.providers
|
125
|
+
["freeipmi", "ipmitool"]
|
126
|
+
end
|
127
|
+
|
128
|
+
# returns true if any of the providers are installed
|
129
|
+
def self.provider_installed?
|
130
|
+
providers_installed?.length > 0
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.providers_installed?
|
134
|
+
available = []
|
135
|
+
providers.each do |prov|
|
136
|
+
if is_provider_installed?(prov)
|
137
|
+
available << prov
|
88
138
|
end
|
89
|
-
return available
|
90
139
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
140
|
+
return available
|
141
|
+
end
|
142
|
+
|
143
|
+
# gets data from the bmc device and puts in a hash for diagnostics
|
144
|
+
def self.get_diag(user, pass, host)
|
145
|
+
data = {}
|
146
|
+
|
147
|
+
if Rubyipmi.is_provider_installed?('freeipmi')
|
148
|
+
@freeconn = Rubyipmi::connect(user, pass, host, 'freeipmi')
|
149
|
+
if @freeconn
|
150
|
+
puts "Retrieving freeipmi data"
|
151
|
+
data['freeipmi'] = @freeconn.get_diag
|
102
152
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
153
|
+
end
|
154
|
+
if Rubyipmi.is_provider_installed?('ipmitool')
|
155
|
+
@ipmiconn = Rubyipmi::connect(user, pass, host, 'ipmitool')
|
156
|
+
if @ipmiconn
|
157
|
+
puts "Retrieving ipmitool data"
|
158
|
+
data['ipmitool'] = @ipmiconn.get_diag
|
109
159
|
end
|
110
|
-
return data
|
111
160
|
end
|
161
|
+
return data
|
162
|
+
end
|
112
163
|
|
113
164
|
end
|
data/rubyipmi.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: rubyipmi 0.8.1 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "rubyipmi"
|
8
|
-
s.version = "0.
|
9
|
+
s.version = "0.8.1"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Corey Osman"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2014-10-02"
|
13
15
|
s.description = "Provides a library for controlling IPMI devices using pure ruby code"
|
14
16
|
s.email = "corey@logicminds.biz"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -22,6 +24,7 @@ Gem::Specification.new do |s|
|
|
22
24
|
"LICENSE.txt",
|
23
25
|
"README.md",
|
24
26
|
"README.rdoc",
|
27
|
+
"RELEASE_NOTES.md",
|
25
28
|
"Rakefile",
|
26
29
|
"VERSION",
|
27
30
|
"lib/rubyipmi.rb",
|
@@ -102,8 +105,7 @@ Gem::Specification.new do |s|
|
|
102
105
|
]
|
103
106
|
s.homepage = "http://github.com/logicminds/rubyipmi"
|
104
107
|
s.licenses = ["GPLv3"]
|
105
|
-
s.
|
106
|
-
s.rubygems_version = "2.0.7"
|
108
|
+
s.rubygems_version = "2.2.1"
|
107
109
|
s.summary = "A ruby wrapper for ipmi command line tools that supports ipmitool and freeipmi"
|
108
110
|
|
109
111
|
if s.respond_to? :specification_version then
|
@@ -114,7 +116,6 @@ Gem::Specification.new do |s|
|
|
114
116
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
115
117
|
s.add_development_dependency(%q<bundler>, [">= 1.1.5"])
|
116
118
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
117
|
-
s.add_development_dependency(%q<rcov>, ["< 1.0.0"])
|
118
119
|
s.add_development_dependency(%q<highline>, [">= 0"])
|
119
120
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
120
121
|
else
|
@@ -122,7 +123,6 @@ Gem::Specification.new do |s|
|
|
122
123
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
123
124
|
s.add_dependency(%q<bundler>, [">= 1.1.5"])
|
124
125
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
125
|
-
s.add_dependency(%q<rcov>, ["< 1.0.0"])
|
126
126
|
s.add_dependency(%q<highline>, [">= 0"])
|
127
127
|
s.add_dependency(%q<rake>, [">= 0"])
|
128
128
|
end
|
@@ -131,7 +131,6 @@ Gem::Specification.new do |s|
|
|
131
131
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
132
132
|
s.add_dependency(%q<bundler>, [">= 1.1.5"])
|
133
133
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
134
|
-
s.add_dependency(%q<rcov>, ["< 1.0.0"])
|
135
134
|
s.add_dependency(%q<highline>, [">= 0"])
|
136
135
|
s.add_dependency(%q<rake>, [">= 0"])
|
137
136
|
end
|
@@ -15,7 +15,7 @@ describe "Bmc" do
|
|
15
15
|
host = "ipmihost"
|
16
16
|
Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
17
|
|
18
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
18
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
19
19
|
@bmcinfo = @conn.bmc.information
|
20
20
|
data = nil
|
21
21
|
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
@@ -26,17 +26,14 @@ describe "Bmc" do
|
|
26
26
|
$?.stub(:success?).and_return(true)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
it "cmd should be bmc-info with correct number of arguments" do
|
30
30
|
@bmcinfo.retrieve
|
31
31
|
verify_freeipmi_command(@bmcinfo, 2, "#{@path}/bmc-info")
|
32
|
-
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
it "cmd should be bmc-info with correct number of arguments" do
|
35
35
|
@bmcinfo.guid
|
36
36
|
verify_freeipmi_command(@bmcinfo, 3, "#{@path}/bmc-info")
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
end
|
41
38
|
|
42
39
|
end
|
@@ -15,7 +15,7 @@ describe "Bmc" do
|
|
15
15
|
host = "ipmihost"
|
16
16
|
Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
17
17
|
|
18
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
18
|
+
@conn = Rubyipmi.connect(user, pass, host, provider,{:debug => true})
|
19
19
|
@bmc = @conn.bmc
|
20
20
|
data = nil
|
21
21
|
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
@@ -7,17 +7,18 @@ describe "Bmc" do
|
|
7
7
|
|
8
8
|
before :all do
|
9
9
|
@path = '/usr/local/bin'
|
10
|
+
@provider = "freeipmi"
|
11
|
+
@user = "ipmiuser"
|
12
|
+
@pass = "impipass"
|
13
|
+
@host = "ipmihost"
|
10
14
|
end
|
11
15
|
|
12
16
|
before :each do
|
13
17
|
|
14
|
-
|
15
|
-
user = "ipmiuser"
|
16
|
-
pass = "impipass"
|
17
|
-
host = "ipmihost"
|
18
|
+
|
18
19
|
Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
19
20
|
|
20
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
21
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
|
21
22
|
|
22
23
|
|
23
24
|
end
|
@@ -52,5 +53,50 @@ describe "Bmc" do
|
|
52
53
|
|
53
54
|
end
|
54
55
|
|
56
|
+
it 'object should have debug set to true' do
|
57
|
+
@conn.debug.should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'object should have driver set to auto if not specified' do
|
61
|
+
@conn.options.has_key?('driver-type').should be_false
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'object should have driver set to auto if not specified' do
|
65
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
66
|
+
@conn.options.has_key?('driver-type').should be_false
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'object should have priv type set to ADMINISTRATOR if not specified' do
|
70
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
71
|
+
@conn.options.has_key?('privilege-level').should be_false
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'object should have priv type set to USER ' do
|
75
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
|
76
|
+
@conn.options.fetch('privilege-level').should eq('USER')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should raise exception if invalid privilege type' do
|
80
|
+
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'BLAH',:debug => true, :driver => 'auto'})}.to raise_error(RuntimeError)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should raise exception if invalid driver type' do
|
84
|
+
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'foo'})}.to raise_error(RuntimeError)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'object should have driver set to lan_2_0' do
|
88
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
|
89
|
+
@conn.options['driver-type'].should eq('LAN_2_0')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'object should have driver set to lan' do
|
93
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
|
94
|
+
@conn.options['driver-type'].should eq('LAN')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'object should have driver set to openipmi' do
|
98
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
|
99
|
+
@conn.options['driver-type'].should eq('OPENIPMI')
|
100
|
+
end
|
55
101
|
|
56
102
|
end
|
@@ -16,7 +16,7 @@ describe :Fru do
|
|
16
16
|
host = "ipmihost"
|
17
17
|
Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
18
18
|
|
19
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
19
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
20
20
|
@fru = @conn.fru
|
21
21
|
File.open("spec/fixtures/#{provider}/fru.txt",'r') do |file|
|
22
22
|
data = file.read
|
@@ -14,7 +14,7 @@ describe :Sensors do
|
|
14
14
|
# this stub allows us to mock the command that would be used to verify provider installation
|
15
15
|
Rubyipmi.stub(:locate_command).with('ipmipower').and_return("#{@path}/ipmipower")
|
16
16
|
|
17
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
17
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
18
18
|
@sensors = @conn.sensors
|
19
19
|
File.open("spec/fixtures/#{provider}/sensors.txt",'r') do |file|
|
20
20
|
data = file.read
|
@@ -15,7 +15,7 @@ describe "Bmc" do
|
|
15
15
|
pass = "impipass"
|
16
16
|
host = "ipmihost"
|
17
17
|
Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
18
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
18
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
19
19
|
@bmc = @conn.bmc
|
20
20
|
data = nil
|
21
21
|
File.open("spec/fixtures/#{provider}/bmc_info.txt",'r') do |file|
|
@@ -4,15 +4,16 @@ describe :Connection do
|
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@path = '/usr/local/bin'
|
7
|
+
@provider = "ipmitool"
|
8
|
+
@user = "ipmiuser"
|
9
|
+
@pass = "impipass"
|
10
|
+
@host = "ipmihost"
|
7
11
|
end
|
8
12
|
|
9
13
|
before :each do
|
10
|
-
|
11
|
-
user = "ipmiuser"
|
12
|
-
pass = "impipass"
|
13
|
-
host = "ipmihost"
|
14
|
+
|
14
15
|
Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
15
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
16
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true})
|
16
17
|
|
17
18
|
end
|
18
19
|
|
@@ -53,6 +54,46 @@ describe :Connection do
|
|
53
54
|
@conn.debug.should be_true
|
54
55
|
end
|
55
56
|
|
57
|
+
it 'object should have driver set to auto if not specified' do
|
58
|
+
@conn.options.has_key?('driver-type').should be_false
|
59
|
+
end
|
56
60
|
|
61
|
+
it 'object should have driver set to auto if not specified' do
|
62
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
63
|
+
@conn.options.has_key?('I').should be_false
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should raise exception if invalid driver type' do
|
67
|
+
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'foo'})}.to raise_error(RuntimeError)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'object should have priv type set to ADMINISTRATOR if not specified' do
|
71
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'auto'})
|
72
|
+
@conn.options.has_key?('L').should be_false
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'object should have priv type set to USER ' do
|
76
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'USER', :debug => true, :driver => 'auto'})
|
77
|
+
@conn.options.fetch('L').should eq('USER')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should raise exception if invalid privilege type' do
|
81
|
+
expect{Rubyipmi.connect(@user, @pass, @host, @provider,{:privilege => 'BLAH',:debug => true, :driver => 'auto'})}.to raise_error(RuntimeError)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'object should have driver set to lanplus' do
|
85
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan20'})
|
86
|
+
@conn.options['I'].should eq('lanplus')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'object should have driver set to lanplus' do
|
90
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'lan15'})
|
91
|
+
@conn.options['I'].should eq('lan')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'object should have driver set to open' do
|
95
|
+
@conn = Rubyipmi.connect(@user, @pass, @host, @provider,{:debug => true, :driver => 'open'})
|
96
|
+
@conn.options['I'].should eq('open')
|
97
|
+
end
|
57
98
|
|
58
99
|
end
|
@@ -15,7 +15,7 @@ describe :Fru do
|
|
15
15
|
host = "ipmihost"
|
16
16
|
Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
17
17
|
|
18
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
18
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
19
19
|
@fru = @conn.fru
|
20
20
|
|
21
21
|
File.open("spec/fixtures/#{provider}/fru.txt",'r') do |file|
|
@@ -12,7 +12,7 @@ describe "Lan" do
|
|
12
12
|
pass = "impipass"
|
13
13
|
host = "ipmihost"
|
14
14
|
Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
15
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
15
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
16
16
|
@lan = @conn.bmc.lan
|
17
17
|
data = nil
|
18
18
|
File.open("spec/fixtures/#{provider}/lan.txt",'r') do |file|
|
@@ -14,7 +14,7 @@ describe :Sensors do
|
|
14
14
|
host = "ipmihost"
|
15
15
|
Rubyipmi.stub(:locate_command).with('ipmitool').and_return("#{@path}/ipmitool")
|
16
16
|
|
17
|
-
@conn = Rubyipmi.connect(user, pass, host, provider, true)
|
17
|
+
@conn = Rubyipmi.connect(user, pass, host, provider, {:debug => true})
|
18
18
|
@sensors = @conn.sensors
|
19
19
|
File.open("spec/fixtures/#{provider}/sensors.txt",'r') do |file|
|
20
20
|
data = file.read
|