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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d71a0a1e0d59728f61b38be628466e17f2a27b837138e538682afef45ee2d5a
|
4
|
+
data.tar.gz: a7df4346c51b1147ecc1060a6b7c66a37a111fd78366fc9feadeb4b889900ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca95d910f47ef78d95ffec0c67c7b5109c3b2d37be8e1068ed9f087c9bc77dbabd0eda7121c5d819ac9c6a94db7d09a4aeff3e147419913fc4b370447b969dd4
|
7
|
+
data.tar.gz: 3418f3612947c775531ae3a1102953d8457e6887c4d01992f19d2cf2fec0d5a5fc7303b12a1c74ad2438fda471981075a57af9a036f57fe19c6d815b5997d41f
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
.idea/
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
.vagrant/
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
Gemfile.lock
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
Gemfile.lock
|
15
|
+
|
16
|
+
# jeweler generated
|
17
|
+
pkg
|
18
|
+
.vagrant
|
19
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
20
|
+
#
|
21
|
+
# * Create a file at ~/.gitignore
|
22
|
+
# * Include files you want ignored
|
23
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
24
|
+
#
|
25
|
+
# After doing this, these files will be ignored in all your git projects,
|
26
|
+
# saving you from having to 'pollute' every project you touch with them
|
27
|
+
#
|
28
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
29
|
+
#
|
30
|
+
# For MacOS:
|
31
|
+
#
|
32
|
+
#.DS_Store
|
33
|
+
|
34
|
+
# For TextMate
|
35
|
+
#*.tmproj
|
36
|
+
#tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
#*~
|
40
|
+
#\#*
|
41
|
+
#.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
#*.swp
|
45
|
+
|
46
|
+
# For redcar:
|
47
|
+
#.redcar
|
48
|
+
|
49
|
+
# For rubinius:
|
50
|
+
#*.rbc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
Style/StringLiterals:
|
2
|
+
Enabled: false
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'rubyipmi.gemspec'
|
6
|
+
SignalException:
|
7
|
+
EnforcedStyle: only_raise
|
8
|
+
Documentation:
|
9
|
+
Enabled: false
|
10
|
+
ClassAndModuleChildren:
|
11
|
+
Enabled: false
|
12
|
+
HashSyntax:
|
13
|
+
EnforcedStyle: hash_rockets
|
14
|
+
ClassCheck:
|
15
|
+
EnforcedStyle: kind_of?
|
16
|
+
SpaceInsideHashLiteralBraces:
|
17
|
+
EnforcedStyle: no_space
|
18
|
+
Style/WordArray:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
|
22
|
+
# TODO: fix these
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Max: 60
|
25
|
+
Metrics/CyclomaticComplexity:
|
26
|
+
Max: 19
|
27
|
+
Metrics/LineLength:
|
28
|
+
Max: 149
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Max: 44
|
31
|
+
Metrics/ModuleLength:
|
32
|
+
Max: 128
|
33
|
+
Metrics/PerceivedComplexity:
|
34
|
+
Max: 22
|
35
|
+
Style/SpecialGlobalVars:
|
36
|
+
Exclude:
|
37
|
+
- 'lib/rubyipmi.rb'
|
38
|
+
- 'lib/rubyipmi/commands/basecommand.rb'
|
39
|
+
- 'lib/rubyipmi/freeipmi/commands/fru.rb'
|
40
|
+
- 'lib/rubyipmi/ipmitool/commands/fru.rb'
|
41
|
+
Style/RescueModifier:
|
42
|
+
Exclude:
|
43
|
+
- 'lib/rubyipmi.rb'
|
44
|
+
Style/RegexpLiteral:
|
45
|
+
Exclude:
|
46
|
+
- 'spec/spec_helper.rb'
|
47
|
+
Style/PredicateName:
|
48
|
+
Exclude:
|
49
|
+
- 'lib/rubyipmi.rb'
|
50
|
+
Lint/RescueException:
|
51
|
+
Exclude:
|
52
|
+
- 'spec/integration/rubyipmi_spec.rb'
|
53
|
+
Style/AccessorMethodName:
|
54
|
+
Exclude:
|
55
|
+
- 'lib/rubyipmi/freeipmi/connection.rb'
|
56
|
+
- 'lib/rubyipmi/ipmitool/connection.rb'
|
57
|
+
|
58
|
+
# Fixed by deprecation
|
59
|
+
Style/MethodName:
|
60
|
+
Exclude:
|
61
|
+
- 'lib/rubyipmi/commands/mixins/power_mixin.rb'
|
62
|
+
|
63
|
+
# Don't understand
|
64
|
+
Style/FileName:
|
65
|
+
Exclude:
|
66
|
+
- 'spec/unit/freeipmi/bmc-info_spec.rb'
|
data/.travis.yml
ADDED
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
@@ -135,9 +135,15 @@ from the standard. In general this library should work will all servers.
|
|
135
135
|
```ruby
|
136
136
|
require 'rubyipmi'
|
137
137
|
conn = Rubyipmi.connect("username", "password", "hostname")
|
138
|
-
conn.chassis.bootpxe(
|
139
|
-
conn.chassis.bootdisk(
|
140
|
-
|
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
|
141
147
|
```
|
142
148
|
|
143
149
|
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
### 0.11.0
|
2
|
+
This is a big update with many minor changes and bug fixes. Thank you for all that submitted fixes.
|
3
|
+
- Removes jeweler dependency and replaces with bundler commands, updates gemspec
|
4
|
+
- Use HTTPS for homepage field in the gemspec
|
5
|
+
- Fix infinite loop when executing 'lan print' command
|
6
|
+
- The retry count counter is currently not incremented, so in the situation
|
7
|
+
when this command fails, library enters infinite loop of executing this
|
8
|
+
command, which is bad.
|
9
|
+
|
10
|
+
Adds a missing counter incrementation with the same style as
|
11
|
+
in basecommands and make it return current @info in case of a failure,
|
12
|
+
so all methods accessing it will just get return nil.
|
13
|
+
|
14
|
+
- Leverage Enumerable#each_with_object
|
15
|
+
- Add a SensorsMixin to remove duplicate code
|
16
|
+
- Enable Rubocop GuardClause and fix complaints
|
17
|
+
- Remove duplicate methods
|
18
|
+
- Fixes "NoMethodError: undefined method `success?' for nil:NilClass"
|
19
|
+
- Some ruby versions need to require 'English' otherwise $CHILD_STATUS is nil
|
20
|
+
- Fix rubocop Style/MethodName "Use snake_case for method names."
|
21
|
+
- Rename private method
|
22
|
+
- Add deprecation warnings for two public methods
|
23
|
+
- Delete unused method
|
24
|
+
- Update .rubocop.yml accordingly
|
25
|
+
- Refactor duplicated chassis power command methods
|
26
|
+
- Adds additional rubycops
|
27
|
+
- Fixes many rubycop infractions
|
28
|
+
- Remove puppet code and vagrant
|
29
|
+
- Remove if / else logic and unnecessary return in #validate_status
|
30
|
+
- Reword confusing project description
|
31
|
+
- Update README.md section on booting to specific devices
|
32
|
+
- Update documentation around bootpxe, bootdisk functions
|
33
|
+
- Remove pry statement from method
|
1
34
|
### 0.10.0
|
2
35
|
* gh-26 - make the driver default to lan20
|
3
36
|
|
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
|
@@ -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
|