rubyipmi 0.9.2 → 0.11.1
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/Gemfile +3 -3
- data/README.md +36 -23
- data/RELEASE_NOTES.md +48 -0
- data/Rakefile +15 -42
- data/VERSION +1 -1
- 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 +31 -28
- data/rubyipmi.gemspec +17 -128
- metadata +13 -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 -120
- 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 -121
- 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 -32
- data/spec/vagrant +0 -27
- data/spec/vagrant.pub +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ded5dae3237a5610e1b3d5e1595743be1401636b68b76965d9b1c4bfaa174ac8
|
|
4
|
+
data.tar.gz: bbfd85a434bfafdeccd6efbcea2dc898032b04b92ceb6c7ebe918f11ac12e4eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60e95d651aa6b3275f91ea531628c33a473eaaf3d3e34c7c60a61d97cbbcbedfa907356138010eae1d0eda3c0a362316f8fb34e472b594edc834bbd78b0bb619
|
|
7
|
+
data.tar.gz: 1d8bb664adf6c327a238358ace1a90fdff409cbf8b8328d15f7081f1e60f114f55efdfbe754f98f08ce92ea59079ebd970f07834b6c38b14c3300b622e99e84c
|
data/Gemfile
CHANGED
|
@@ -3,11 +3,11 @@ source "http://rubygems.org"
|
|
|
3
3
|
group :development do
|
|
4
4
|
gem "rspec", "~> 3.1"
|
|
5
5
|
gem "rdoc", "~> 3.12"
|
|
6
|
-
gem "bundler", ">=
|
|
7
|
-
gem "jeweler", "~> 2.0.1"
|
|
6
|
+
gem "bundler", ">= 2.0.0"
|
|
8
7
|
gem "highline"
|
|
9
8
|
gem "rake"
|
|
10
|
-
gem 'coveralls', require
|
|
9
|
+
gem 'coveralls', :require => false
|
|
11
10
|
gem 'pry'
|
|
12
11
|
gem 'pry-rescue'
|
|
12
|
+
gem "rubocop", "~> 0.33.0", :require => false
|
|
13
13
|
end
|
data/README.md
CHANGED
|
@@ -78,39 +78,46 @@ from the standard. In general this library should work will all servers.
|
|
|
78
78
|
1. Install the freeipmi from source (http://www.gnu.org/software/freeipmi/) or ipmitool
|
|
79
79
|
2. `gem install rubyipmi`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
### Create a connection object
|
|
82
82
|
|
|
83
83
|
```ruby
|
|
84
84
|
require 'rubyipmi'
|
|
85
85
|
conn = Rubyipmi.connect("username", "password", "hostname", "providertype")
|
|
86
|
-
|
|
87
86
|
```
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
Additionally, if your using [openipmi](http://openipmi.sourceforge.net) and will be using rubyipmi to connect to
|
|
89
|
+
the
localhost you can utilize the openipmi driver and not have to pass in any connection parameters.
|
|
90
|
+
Openipmi works
by installing a driver and makes it available to the host. Freeipmi/Ipmitool will then try to use
|
|
91
|
+
this driver to
automatically use the openipmi if no host is given. The one caveat here is that you cannot control
|
|
92
|
+
remote hosts using
openipmi. The rubyipmi code must be executed on the host you want to control.
|
|
93
|
+
The upside is that you don't need
any credentials. Some commands may require root privileges to run when using openipmi.
|
|
94
|
+
|
|
95
|
+
Providertype: optional
|
|
96
|
+
|
|
97
|
+
valid options: 'auto', 'ipmitool', 'freeipmi'
|
|
90
98
|
|
|
91
99
|
If you don't specify the provider type, Rubyipmi will detect if freeipmi or ipmitool
|
|
92
100
|
is installed and load the first tool found. If you specify the provider type rubyipmi will only use that specific
|
|
93
101
|
provider.
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
localhost you can utilize the openipmi driver and not have to pass in any connection parameters. Openipmi works
|
|
97
|
-
by installing a driver and makes it available to the host. Freeipmi/Ipmitool will then try to use this driver to
|
|
98
|
-
automatically use the openipmi if no host is given. The one caveat here is that you cannot control remote hosts using
|
|
99
|
-
openipmi. The rubyipmi code must be executed on the host you want to control. The upside is that you don't need
|
|
100
|
-
any credentials. Some commands may require root privileges to run when using openipmi.
|
|
101
|
-
|
|
103
|
+
You can specify additional options by passing an options hash into the connection method
|
|
102
104
|
```ruby
|
|
103
|
-
conn = Rubyipmi.connect
|
|
104
|
-
conn.power.status
|
|
105
|
+
conn = Rubyipmi.connect("username", "password", "hostname", 'freeipmi', {:privilege =>'USER', :driver => 'lan20'})
|
|
105
106
|
```
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
Privilege
|
|
109
|
+
|
|
110
|
+
This option controls the role of the user making the ipmi call.
|
|
111
|
+
valid options: 'CALLBACK', 'USER', 'OPERATOR', 'ADMINISTRATOR' -- defaults to nil and uses the freeipmi/ipmitool default
|
|
112
|
+
|
|
113
|
+
Driver
|
|
111
114
|
|
|
115
|
+
This option allows you to control which driver to use when making IPMI calls. Selecting auto will choose
|
|
116
|
+
either lan15 or lan20 based on your device. The open type is when using openipmi in conjunction with the provider.
|
|
117
|
+
valid options: "auto", "lan15", "lan20", "open" -- defaults to lan20
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
|
|
120
|
+
### power functions
|
|
114
121
|
|
|
115
122
|
```ruby
|
|
116
123
|
require 'rubyipmi'
|
|
@@ -123,18 +130,24 @@ from the standard. In general this library should work will all servers.
|
|
|
123
130
|
|
|
124
131
|
```
|
|
125
132
|
|
|
126
|
-
|
|
133
|
+
### Boot to specific device
|
|
127
134
|
|
|
128
135
|
```ruby
|
|
129
136
|
require 'rubyipmi'
|
|
130
137
|
conn = Rubyipmi.connect("username", "password", "hostname")
|
|
131
|
-
conn.chassis.bootpxe(
|
|
132
|
-
conn.chassis.bootdisk(
|
|
133
|
-
|
|
138
|
+
conn.chassis.bootpxe(reboot=bool, persistent=bool)
|
|
139
|
+
conn.chassis.bootdisk(reboot=bool, persistent=bool)
|
|
140
|
+
|
|
141
|
+
Examples:
|
|
142
|
+
conn.chassis.bootpxe(reboot=true, persistent=false) # reboot immediately, PXE boot once
|
|
143
|
+
conn.chassis.bootpxe(reboot=false, persistent=false) # on next reboot PXE boot once
|
|
144
|
+
conn.chassis.bootdisk(reboot=true, persistent=false) # reboot immediately, boot off disk once
|
|
145
|
+
conn.chassis.bootdisk(reboot=true, persistent=true) # reboot immediately, boot off disk forever
|
|
146
|
+
conn.chassis.bootdisk(reboot=false, persistent=true) # reboot off disk forever, starting on next reboot
|
|
134
147
|
```
|
|
135
148
|
|
|
136
149
|
|
|
137
|
-
|
|
150
|
+
### Sensors
|
|
138
151
|
|
|
139
152
|
```ruby
|
|
140
153
|
require 'rubyipmi'
|
|
@@ -145,7 +158,7 @@ from the standard. In general this library should work will all servers.
|
|
|
145
158
|
|
|
146
159
|
```
|
|
147
160
|
|
|
148
|
-
|
|
161
|
+
### Fru
|
|
149
162
|
|
|
150
163
|
```ruby
|
|
151
164
|
require 'rubyipmi'
|
data/RELEASE_NOTES.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
### 0.11.1
|
|
2
|
+
* remove hidden files from gem package
|
|
3
|
+
|
|
4
|
+
### 0.11.0
|
|
5
|
+
This is a big update with many minor changes and bug fixes. Thank you for all that submitted fixes.
|
|
6
|
+
- Removes jeweler dependency and replaces with bundler commands, updates gemspec
|
|
7
|
+
- Use HTTPS for homepage field in the gemspec
|
|
8
|
+
- Fix infinite loop when executing 'lan print' command
|
|
9
|
+
- The retry count counter is currently not incremented, so in the situation
|
|
10
|
+
when this command fails, library enters infinite loop of executing this
|
|
11
|
+
command, which is bad.
|
|
12
|
+
|
|
13
|
+
Adds a missing counter incrementation with the same style as
|
|
14
|
+
in basecommands and make it return current @info in case of a failure,
|
|
15
|
+
so all methods accessing it will just get return nil.
|
|
16
|
+
|
|
17
|
+
- Leverage Enumerable#each_with_object
|
|
18
|
+
- Add a SensorsMixin to remove duplicate code
|
|
19
|
+
- Enable Rubocop GuardClause and fix complaints
|
|
20
|
+
- Remove duplicate methods
|
|
21
|
+
- Fixes "NoMethodError: undefined method `success?' for nil:NilClass"
|
|
22
|
+
- Some ruby versions need to require 'English' otherwise $CHILD_STATUS is nil
|
|
23
|
+
- Fix rubocop Style/MethodName "Use snake_case for method names."
|
|
24
|
+
- Rename private method
|
|
25
|
+
- Add deprecation warnings for two public methods
|
|
26
|
+
- Delete unused method
|
|
27
|
+
- Update .rubocop.yml accordingly
|
|
28
|
+
- Refactor duplicated chassis power command methods
|
|
29
|
+
- Adds additional rubycops
|
|
30
|
+
- Fixes many rubycop infractions
|
|
31
|
+
- Remove puppet code and vagrant
|
|
32
|
+
- Remove if / else logic and unnecessary return in #validate_status
|
|
33
|
+
- Reword confusing project description
|
|
34
|
+
- Update README.md section on booting to specific devices
|
|
35
|
+
- Update documentation around bootpxe, bootdisk functions
|
|
36
|
+
- Remove pry statement from method
|
|
37
|
+
### 0.10.0
|
|
38
|
+
* gh-26 - make the driver default to lan20
|
|
39
|
+
|
|
40
|
+
Users of older IPMI devices will now need to pass the specified driver type.
|
|
41
|
+
|
|
42
|
+
### 0.9.3
|
|
43
|
+
* normalize the options being passed into the connect method
|
|
44
|
+
|
|
45
|
+
### 0.9.2
|
|
46
|
+
* fixes an issue where is_provider_installed? should only return a boolean value instead of raising and error
|
|
47
|
+
* fixes a minor style issue where providers_installed? was returning an array when a boolean might have been expected
|
|
48
|
+
|
|
1
49
|
### 0.9.1
|
|
2
50
|
* fixes an issue with connection_works? api call when command raises an error
|
|
3
51
|
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
require 'bundler/gem_tasks'
|
|
2
3
|
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'bundler'
|
|
5
4
|
@base_dir = File.dirname(__FILE__)
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
begin
|
|
9
7
|
Bundler.setup(:default, :development)
|
|
10
8
|
rescue Bundler::BundlerError => e
|
|
@@ -13,29 +11,6 @@ rescue Bundler::BundlerError => e
|
|
|
13
11
|
exit e.status_code
|
|
14
12
|
end
|
|
15
13
|
require 'rake'
|
|
16
|
-
|
|
17
|
-
require 'jeweler'
|
|
18
|
-
Jeweler::Tasks.new do |gem|
|
|
19
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
20
|
-
gem.name = "rubyipmi"
|
|
21
|
-
gem.homepage = "http://github.com/logicminds/rubyipmi"
|
|
22
|
-
gem.license = "LGPLv2.1"
|
|
23
|
-
gem.summary = %Q{A ruby wrapper for ipmi command line tools that supports ipmitool and freeipmi}
|
|
24
|
-
gem.description = %Q{Provides a library for controlling IPMI devices using pure ruby code}
|
|
25
|
-
gem.email = "corey@logicminds.biz"
|
|
26
|
-
gem.authors = ["Corey Osman"]
|
|
27
|
-
gem.files.exclude '.travis.yml'
|
|
28
|
-
gem.files.exclude 'Gemfile.lock'
|
|
29
|
-
gem.files.exclude '.rspec'
|
|
30
|
-
gem.files.exclude '.gitignore'
|
|
31
|
-
gem.files.exclude '.document'
|
|
32
|
-
gem.files.exclude 'coverage/'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# dependencies defined in Gemfile
|
|
36
|
-
end
|
|
37
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
38
|
-
|
|
39
14
|
require 'rspec/core'
|
|
40
15
|
require 'rspec/core/rake_task'
|
|
41
16
|
|
|
@@ -45,9 +20,8 @@ RSpec::Core::RakeTask.new(:unit) do |spec|
|
|
|
45
20
|
end
|
|
46
21
|
|
|
47
22
|
desc "Run integrations tests against real systems using a vagrant box"
|
|
48
|
-
task :vintegration, :user, :pass, :host do |
|
|
23
|
+
task :vintegration, :user, :pass, :host do |_task, args|
|
|
49
24
|
vars = "ipmiuser=#{args[:user]} ipmipass=#{args[:pass]} ipmihost=#{args[:host]}"
|
|
50
|
-
ipmiprovider="freeipmi"
|
|
51
25
|
puts `cd #{@base_dir}/spec && vagrant up`
|
|
52
26
|
puts `cd #{@base_dir}/spec && vagrant provision`
|
|
53
27
|
puts `vagrant ssh \"/rubyipmi/rake integration #{vars}\"`
|
|
@@ -58,9 +32,9 @@ RSpec::Core::RakeTask.new :integration do |spec|
|
|
|
58
32
|
ENV['ipmiuser'] = 'admin'
|
|
59
33
|
ENV['ipmipass'] = 'password'
|
|
60
34
|
ENV['ipmihost'] = '10.0.1.16'
|
|
61
|
-
providers ||=
|
|
35
|
+
providers ||= Array(ENV['ipmiprovider']) || ['freeipmi', 'ipmitool']
|
|
62
36
|
|
|
63
|
-
providers.each do |
|
|
37
|
+
providers.each do |provider|
|
|
64
38
|
ENV['ipmiprovider'] = provider
|
|
65
39
|
spec.pattern = FileList['spec/integration/**/*_spec.rb']
|
|
66
40
|
end
|
|
@@ -79,7 +53,7 @@ Rake::RDocTask.new do |rdoc|
|
|
|
79
53
|
end
|
|
80
54
|
|
|
81
55
|
desc "send diagnostics to logicminds for testing for the given host"
|
|
82
|
-
task :send_diag, :user, :pass, :host do |
|
|
56
|
+
task :send_diag, :user, :pass, :host do |_t, args|
|
|
83
57
|
require 'rubyipmi'
|
|
84
58
|
require 'net/smtp'
|
|
85
59
|
require 'json'
|
|
@@ -91,20 +65,19 @@ task :send_diag, :user, :pass, :host do |t, args |
|
|
|
91
65
|
data = Rubyipmi.get_diag(args[:user], args[:pass], args[:host])
|
|
92
66
|
emailto = 'corey@logicminds.biz'
|
|
93
67
|
subject = "Rubyipmi diagnostics data"
|
|
94
|
-
send_email(emailto, data.to_json,
|
|
95
|
-
|
|
68
|
+
send_email(emailto, data.to_json, :subject => subject)
|
|
96
69
|
end
|
|
97
70
|
|
|
98
|
-
def send_email(to,data, opts={})
|
|
71
|
+
def send_email(to, data, opts = {})
|
|
99
72
|
gmail_id = ask("Enter your gmail account: ")
|
|
100
73
|
pass = ask("Enter your gmail password: ") { |q| q.echo = '*' }
|
|
101
74
|
opts[:from] = gmail_id
|
|
102
|
-
opts[:server]
|
|
103
|
-
opts[:from_alias]
|
|
104
|
-
opts[:subject]
|
|
105
|
-
opts[:body]
|
|
106
|
-
opts[:to]
|
|
107
|
-
opts[:port]
|
|
75
|
+
opts[:server] ||= 'smtp.gmail.com'
|
|
76
|
+
opts[:from_alias] ||= gmail_id
|
|
77
|
+
opts[:subject] ||= @subject
|
|
78
|
+
opts[:body] ||= data
|
|
79
|
+
opts[:to] ||= to
|
|
80
|
+
opts[:port] ||= 587
|
|
108
81
|
msg = <<END_OF_MESSAGE
|
|
109
82
|
From: #{opts[:from_alias]} <#{opts[:from]}>
|
|
110
83
|
To: <#{to}>
|
|
@@ -114,9 +87,9 @@ Date: #{Time.now.rfc2822}
|
|
|
114
87
|
#{opts[:body]}
|
|
115
88
|
END_OF_MESSAGE
|
|
116
89
|
|
|
117
|
-
smtp = Net::SMTP.new(opts[:server],opts[:port])
|
|
90
|
+
smtp = Net::SMTP.new(opts[:server], opts[:port])
|
|
118
91
|
smtp.enable_starttls
|
|
119
|
-
smtp.start(opts[:server],gmail_id,pass
|
|
92
|
+
smtp.start(opts[:server], gmail_id, pass, :login) do
|
|
120
93
|
smtp.send_message(msg, gmail_id, to)
|
|
121
94
|
end
|
|
122
95
|
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.10.0
|
|
@@ -3,7 +3,6 @@ require 'tempfile'
|
|
|
3
3
|
require 'rubyipmi'
|
|
4
4
|
|
|
5
5
|
module Rubyipmi
|
|
6
|
-
|
|
7
6
|
class BaseCommand
|
|
8
7
|
include Observable
|
|
9
8
|
attr_reader :cmd, :max_retry_count
|
|
@@ -39,7 +38,7 @@ module Rubyipmi
|
|
|
39
38
|
|
|
40
39
|
def locate_command(commandname)
|
|
41
40
|
location = `which #{commandname}`.strip
|
|
42
|
-
|
|
41
|
+
unless $?.success?
|
|
43
42
|
logger.error("#{commandname} command not found, is #{commandname} installed?") if logger
|
|
44
43
|
raise "#{commandname} command not found, is #{commandname} installed?"
|
|
45
44
|
end
|
|
@@ -70,8 +69,7 @@ module Rubyipmi
|
|
|
70
69
|
command = makecommand
|
|
71
70
|
@lastcall = "#{command}"
|
|
72
71
|
@result = `#{command} 2>&1`
|
|
73
|
-
# sometimes the command tool does not return the correct result
|
|
74
|
-
# code
|
|
72
|
+
# sometimes the command tool does not return the correct result, validate it with additional code
|
|
75
73
|
process_status = validate_status($?)
|
|
76
74
|
rescue
|
|
77
75
|
if retrycount < max_retry_count
|
|
@@ -84,7 +82,7 @@ module Rubyipmi
|
|
|
84
82
|
end
|
|
85
83
|
ensure
|
|
86
84
|
removepass
|
|
87
|
-
|
|
85
|
+
process_status
|
|
88
86
|
end
|
|
89
87
|
end
|
|
90
88
|
|
|
@@ -93,30 +91,26 @@ module Rubyipmi
|
|
|
93
91
|
# until all the fixes are exhausted or a error not defined in the errorcodes is found
|
|
94
92
|
# this must be overrided in the subclass, as there are no generic errors that fit both providers
|
|
95
93
|
def find_fix(result)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
end
|
|
94
|
+
return unless result
|
|
95
|
+
# The errorcode code hash contains the fix
|
|
96
|
+
begin
|
|
97
|
+
fix = ErrorCodes.search(result)
|
|
98
|
+
@options.merge_notify!(fix)
|
|
99
|
+
rescue
|
|
100
|
+
Rubyipmi.logger.debug("Could not find fix for error code: \n#{result}") if logger
|
|
101
|
+
raise "Could not find fix for error code: \n#{result}"
|
|
105
102
|
end
|
|
106
103
|
end
|
|
107
104
|
|
|
108
105
|
def update(opts)
|
|
109
|
-
|
|
106
|
+
@options.merge!(opts)
|
|
110
107
|
end
|
|
111
108
|
|
|
112
|
-
|
|
109
|
+
# This method will check if the results are really valid as the exit code can be misleading and incorrect
|
|
113
110
|
def validate_status(exitstatus)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
else
|
|
118
|
-
return true
|
|
119
|
-
end
|
|
111
|
+
raise "Error occurred" unless exitstatus.success?
|
|
112
|
+
|
|
113
|
+
true
|
|
120
114
|
end
|
|
121
115
|
end
|
|
122
|
-
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Rubyipmi
|
|
2
|
+
module PowerMixin
|
|
3
|
+
# Turn the system on
|
|
4
|
+
def on
|
|
5
|
+
command("on")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Turn the system off
|
|
9
|
+
def off
|
|
10
|
+
command("off")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Perform a power reset on the system
|
|
14
|
+
def reset
|
|
15
|
+
command("reset")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Power cycle the system
|
|
19
|
+
def cycle
|
|
20
|
+
off? ? on : command("cycle")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Perform a soft shutdown, like briefly pushing the power button
|
|
24
|
+
def soft_shutdown
|
|
25
|
+
command("soft")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Test to see if the power is on
|
|
29
|
+
def on?
|
|
30
|
+
status == "on"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Test to see if the power is off
|
|
34
|
+
def off?
|
|
35
|
+
status == "off"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# DEPRECATED: Please use soft_shutdown instead.
|
|
39
|
+
def softShutdown
|
|
40
|
+
warn "[DEPRECATION] `softShutdown` is deprecated, please use `soft_shutdown` instead."
|
|
41
|
+
soft_shutdown
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# DEPRECATED: Please use power_interrupt instead.
|
|
45
|
+
def powerInterrupt
|
|
46
|
+
warn "[DEPRECATION] `powerInterrupt` is deprecated, please use `power_interrupt` instead."
|
|
47
|
+
power_interrupt
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Rubyipmi
|
|
2
|
+
module SensorsMixin
|
|
3
|
+
def refresh
|
|
4
|
+
@sensors = nil
|
|
5
|
+
list
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def list
|
|
9
|
+
@sensors ||= parse(getsensors)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def count
|
|
13
|
+
list.count
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def names
|
|
17
|
+
list.keys
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# returns a hash of fan sensors where the key is fan name and value is the sensor
|
|
21
|
+
def fanlist(refreshdata = false)
|
|
22
|
+
refresh if refreshdata
|
|
23
|
+
list.each_with_object({}) { |(name, sensor), flist| flist[name] = sensor if name =~ /.*fan.*/ }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# returns a hash of sensors where each key is the name of the sensor and the value is the sensor
|
|
27
|
+
def templist(refreshdata = false)
|
|
28
|
+
refresh if refreshdata
|
|
29
|
+
list.each_with_object({}) do |(name, sensor), tlist|
|
|
30
|
+
tlist[name] = sensor if (sensor[:unit] =~ /.*degree.*/ || name =~ /.*temp.*/)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def method_missing(method, *_args, &_block)
|
|
37
|
+
if !list.key?(method.to_s)
|
|
38
|
+
raise NoMethodError
|
|
39
|
+
else
|
|
40
|
+
list[method.to_s]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def parse(data)
|
|
45
|
+
return {} if data.nil?
|
|
46
|
+
|
|
47
|
+
data.lines.each_with_object({}) do |line, sensorlist|
|
|
48
|
+
# skip the header
|
|
49
|
+
sensor = sensor_class.new(line)
|
|
50
|
+
sensorlist[sensor[:name]] = sensor
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
require 'rubyipmi/freeipmi/errorcodes'
|
|
2
2
|
|
|
3
3
|
module Rubyipmi::Freeipmi
|
|
4
|
-
|
|
5
4
|
class BaseCommand < Rubyipmi::BaseCommand
|
|
6
|
-
|
|
7
5
|
def setpass
|
|
8
6
|
super
|
|
9
7
|
@options["config-file"] = @passfile.path
|
|
10
|
-
@passfile.write "username #{@options[
|
|
11
|
-
@passfile.write "password #{@options[
|
|
8
|
+
@passfile.write "username #{@options['username']}\n"
|
|
9
|
+
@passfile.write "password #{@options['password']}\n"
|
|
12
10
|
@passfile.close
|
|
13
11
|
end
|
|
14
12
|
|
|
@@ -18,41 +16,36 @@ module Rubyipmi::Freeipmi
|
|
|
18
16
|
|
|
19
17
|
def makecommand
|
|
20
18
|
# need to format the options to freeipmi format
|
|
21
|
-
args = @options.collect
|
|
19
|
+
args = @options.collect do |k, v|
|
|
22
20
|
# must remove from command line as its handled via conf file
|
|
23
21
|
next if k == 'password'
|
|
24
22
|
next if k == 'username'
|
|
25
|
-
if
|
|
23
|
+
if !v
|
|
26
24
|
"--#{k}"
|
|
27
25
|
else
|
|
28
26
|
"--#{k}=#{v}"
|
|
29
27
|
end
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
end.join(" ")
|
|
29
|
+
|
|
30
|
+
"#{cmd} #{args.rstrip}"
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
# This method will check if the results are really valid as the exit code can be misleading and incorrect
|
|
35
34
|
# this is required because freeipmi in older version always returned 0 even if an error occured
|
|
36
35
|
def validate_status(exitstatus)
|
|
37
36
|
case @cmdname
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if @result.length > 100 and exitstatus.success?
|
|
46
|
-
return true
|
|
47
|
-
else
|
|
48
|
-
raise "Error occurred"
|
|
49
|
-
end
|
|
37
|
+
when "ipmipower"
|
|
38
|
+
# until ipmipower returns the correct exit status this is a hack
|
|
39
|
+
# essentially any result greater than 23 characters is an error
|
|
40
|
+
raise "Error occurred" if @result.length > 23
|
|
41
|
+
when "bmc-config"
|
|
42
|
+
if @result.length > 100 && exitstatus.success?
|
|
43
|
+
return true
|
|
50
44
|
else
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
45
|
+
raise "Error occurred"
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
super
|
|
56
49
|
end
|
|
57
50
|
end
|
|
58
51
|
|
|
@@ -60,16 +53,14 @@ module Rubyipmi::Freeipmi
|
|
|
60
53
|
# If a fix is found it is applied to the options hash, and then the last run command is retried
|
|
61
54
|
# until all the fixes are exhausted or a error not defined in the errorcodes is found
|
|
62
55
|
def find_fix(result)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
end
|
|
56
|
+
return unless result
|
|
57
|
+
# The errorcode code hash contains the fix
|
|
58
|
+
begin
|
|
59
|
+
fix = ErrorCodes.search(result)
|
|
60
|
+
@options.merge_notify!(fix)
|
|
61
|
+
rescue
|
|
62
|
+
raise "Could not find fix for error code: \n#{result}"
|
|
71
63
|
end
|
|
72
64
|
end
|
|
73
|
-
|
|
74
65
|
end
|
|
75
|
-
end
|
|
66
|
+
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
module Rubyipmi::Freeipmi
|
|
2
|
-
|
|
3
2
|
class Bmc < Rubyipmi::Freeipmi::BaseCommand
|
|
4
|
-
|
|
5
|
-
#attr_accessor :options
|
|
3
|
+
# attr_accessor :options
|
|
6
4
|
attr_accessor :config
|
|
7
5
|
|
|
8
6
|
def initialize(opts = ObservableHash.new)
|
|
@@ -12,7 +10,7 @@ module Rubyipmi::Freeipmi
|
|
|
12
10
|
|
|
13
11
|
def version
|
|
14
12
|
@options['version'] = false
|
|
15
|
-
|
|
13
|
+
runcmd
|
|
16
14
|
@options.delete_notify('version')
|
|
17
15
|
@result.slice(/\d\.\d.\d/)
|
|
18
16
|
end
|
|
@@ -25,12 +23,12 @@ module Rubyipmi::Freeipmi
|
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
def reset(type='cold')
|
|
26
|
+
def reset(type = 'cold')
|
|
29
27
|
device.reset(type)
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def guid
|
|
33
|
-
|
|
31
|
+
information.guid
|
|
34
32
|
end
|
|
35
33
|
|
|
36
34
|
def config
|
|
@@ -48,6 +46,5 @@ module Rubyipmi::Freeipmi
|
|
|
48
46
|
def device
|
|
49
47
|
@bmcdevice ||= Rubyipmi::Freeipmi::BmcDevice.new(options)
|
|
50
48
|
end
|
|
51
|
-
|
|
52
49
|
end
|
|
53
50
|
end
|