rubyipmi 0.9.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/.document +5 -0
  3. data/.gitignore +50 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +66 -0
  6. data/.travis.yml +13 -0
  7. data/Gemfile +3 -3
  8. data/README.md +96 -25
  9. data/RELEASE_NOTES.md +45 -0
  10. data/Rakefile +15 -42
  11. data/VERSION +1 -1
  12. data/lib/rubyipmi/commands/basecommand.rb +17 -23
  13. data/lib/rubyipmi/commands/mixins/power_mixin.rb +50 -0
  14. data/lib/rubyipmi/commands/mixins/sensors_mixin.rb +54 -0
  15. data/lib/rubyipmi/freeipmi/commands/basecommand.rb +26 -35
  16. data/lib/rubyipmi/freeipmi/commands/bmc.rb +4 -7
  17. data/lib/rubyipmi/freeipmi/commands/bmcconfig.rb +7 -17
  18. data/lib/rubyipmi/freeipmi/commands/bmcdevice.rb +2 -9
  19. data/lib/rubyipmi/freeipmi/commands/bmcinfo.rb +4 -10
  20. data/lib/rubyipmi/freeipmi/commands/chassis.rb +27 -45
  21. data/lib/rubyipmi/freeipmi/commands/chassisconfig.rb +23 -38
  22. data/lib/rubyipmi/freeipmi/commands/fru.rb +23 -42
  23. data/lib/rubyipmi/freeipmi/commands/lan.rb +4 -6
  24. data/lib/rubyipmi/freeipmi/commands/power.rb +8 -51
  25. data/lib/rubyipmi/freeipmi/commands/sensors.rb +10 -67
  26. data/lib/rubyipmi/freeipmi/connection.rb +14 -17
  27. data/lib/rubyipmi/freeipmi/errorcodes.rb +11 -17
  28. data/lib/rubyipmi/ipmitool/commands/basecommand.rb +12 -16
  29. data/lib/rubyipmi/ipmitool/commands/bmc.rb +13 -22
  30. data/lib/rubyipmi/ipmitool/commands/chassis.rb +26 -44
  31. data/lib/rubyipmi/ipmitool/commands/chassisconfig.rb +11 -21
  32. data/lib/rubyipmi/ipmitool/commands/fru.rb +35 -48
  33. data/lib/rubyipmi/ipmitool/commands/lan.rb +25 -28
  34. data/lib/rubyipmi/ipmitool/commands/power.rb +7 -58
  35. data/lib/rubyipmi/ipmitool/commands/sensors.rb +10 -68
  36. data/lib/rubyipmi/ipmitool/connection.rb +10 -19
  37. data/lib/rubyipmi/ipmitool/errorcodes.rb +11 -45
  38. data/lib/rubyipmi/observablehash.rb +1 -2
  39. data/lib/rubyipmi/version.rb +5 -0
  40. data/lib/rubyipmi.rb +33 -30
  41. data/rubyipmi.gemspec +17 -128
  42. metadata +18 -101
  43. data/spec/Vagrantfile +0 -45
  44. data/spec/fixtures/freeipmi/bmc_config.txt +0 -317
  45. data/spec/fixtures/freeipmi/bmc_config_lan_conf.txt +0 -19
  46. data/spec/fixtures/freeipmi/bmc_info.txt +0 -32
  47. data/spec/fixtures/freeipmi/errors.txt +0 -3
  48. data/spec/fixtures/freeipmi/fru.txt +0 -13
  49. data/spec/fixtures/freeipmi/sensors.txt +0 -29
  50. data/spec/fixtures/ipmitool/bmc_info.txt +0 -20
  51. data/spec/fixtures/ipmitool/errors.txt +0 -10
  52. data/spec/fixtures/ipmitool/fru.txt +0 -96
  53. data/spec/fixtures/ipmitool/lan.txt +0 -17
  54. data/spec/fixtures/ipmitool/sensors.txt +0 -105
  55. data/spec/integration/bmc_spec.rb +0 -48
  56. data/spec/integration/chassis_config_spec.rb +0 -38
  57. data/spec/integration/chassis_spec.rb +0 -26
  58. data/spec/integration/connection_spec.rb +0 -45
  59. data/spec/integration/fru_spec.rb +0 -38
  60. data/spec/integration/lan_spec.rb +0 -50
  61. data/spec/integration/power_spec.rb +0 -40
  62. data/spec/integration/rubyipmi_spec.rb +0 -114
  63. data/spec/integration/sensor_spec.rb +0 -43
  64. data/spec/manifests/default.pp +0 -50
  65. data/spec/puppetmodules/archive/LICENSE-2.0.txt +0 -202
  66. data/spec/puppetmodules/archive/Modulefile +0 -8
  67. data/spec/puppetmodules/archive/README.md +0 -40
  68. data/spec/puppetmodules/archive/manifests/download.pp +0 -157
  69. data/spec/puppetmodules/archive/manifests/extract.pp +0 -81
  70. data/spec/puppetmodules/archive/manifests/init.pp +0 -70
  71. data/spec/puppetmodules/archive/manifests/tar-gz.pp +0 -7
  72. data/spec/puppetmodules/archive/manifests/zip.pp +0 -7
  73. data/spec/puppetmodules/archive/metadata.json +0 -26
  74. data/spec/spec_helper.rb +0 -47
  75. data/spec/unit/freeipmi/bmc-info_spec.rb +0 -38
  76. data/spec/unit/freeipmi/bmc_spec.rb +0 -43
  77. data/spec/unit/freeipmi/connection_spec.rb +0 -120
  78. data/spec/unit/freeipmi/errorcodes_spec.rb +0 -28
  79. data/spec/unit/freeipmi/fru_spec.rb +0 -76
  80. data/spec/unit/freeipmi/lan_spec.rb +0 -0
  81. data/spec/unit/freeipmi/sensors_spec.rb +0 -85
  82. data/spec/unit/ipmitool/bmc_spec.rb +0 -77
  83. data/spec/unit/ipmitool/connection_spec.rb +0 -121
  84. data/spec/unit/ipmitool/errorcodes_spec.rb +0 -35
  85. data/spec/unit/ipmitool/fru_spec.rb +0 -77
  86. data/spec/unit/ipmitool/lan_spec.rb +0 -94
  87. data/spec/unit/ipmitool/sensors_spec.rb +0 -96
  88. data/spec/unit/rubyipmi_spec.rb +0 -31
  89. data/spec/vagrant +0 -27
  90. data/spec/vagrant.pub +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 02b0b1ca03e27eaf226f2f876b943d0db218fe07
4
- data.tar.gz: d76b73dbf83a64d85663c304169e9ee24e010ac4
2
+ SHA256:
3
+ metadata.gz: 7d71a0a1e0d59728f61b38be628466e17f2a27b837138e538682afef45ee2d5a
4
+ data.tar.gz: a7df4346c51b1147ecc1060a6b7c66a37a111fd78366fc9feadeb4b889900ac8
5
5
  SHA512:
6
- metadata.gz: 2682146a7c24f31144c1eedbf980cad87b86097fb6338999b60121e1537f427a5eb7be6e87811a2ccfb8200db4af75f38370089f859df885e9538ae337535f3a
7
- data.tar.gz: ca76f38f6f5ad045591030352b8679e3536fe2b38e0d73e2deeef796f85d3f38cb8ab9d9a4326be28f21ae2279ac2376710f6845ba09a441fadb4419550174a9
6
+ metadata.gz: ca95d910f47ef78d95ffec0c67c7b5109c3b2d37be8e1068ed9f087c9bc77dbabd0eda7121c5d819ac9c6a94db7d09a4aeff3e147419913fc4b370447b969dd4
7
+ data.tar.gz: 3418f3612947c775531ae3a1102953d8457e6887c4d01992f19d2cf2fec0d5a5fc7303b12a1c74ad2438fda471981075a57af9a036f57fe19c6d815b5997d41f
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
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
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1.3
6
+ - 2.2
7
+ branches:
8
+ only:
9
+ - master
10
+ - development
11
+ notifications:
12
+ email:
13
+ - corey@logicminds.biz
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", ">= 1.1.5"
7
- gem "jeweler", "~> 2.0.1"
6
+ gem "bundler", ">= 2.0.0"
8
7
  gem "highline"
9
8
  gem "rake"
10
- gem 'coveralls', require: false
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
@@ -1,3 +1,36 @@
1
+ Table of Contents
2
+ =================
3
+
4
+ * [Rubyipmi](#rubyipmi)
5
+ * [Projects that use Rubyipmi](#projects-that-use-rubyipmi)
6
+ * [Support](#support)
7
+ * [Using the library in your code](#using-the-library-in-your-code)
8
+ * [Requirements](#requirements)
9
+ * [Create a connection object](#create-a-connection-object)
10
+ * [Use power functions (not all listed)](#use-power-functions-not-all-listed)
11
+ * [Boot to specific device](#boot-to-specific-device)
12
+ * [Sensors](#sensors)
13
+ * [Fru](#fru)
14
+ * [Testing](#testing)
15
+ * [Security](#security)
16
+ * [How the library works](#how-the-library-works)
17
+ * [Creating a new command](#creating-a-new-command)
18
+ * [Writing a function for running a command](#writing-a-function-for-running-a-command)
19
+ * [Running the cmd](#running-the-cmd)
20
+ * [The Options hash](#the-options-hash)
21
+ * [How to get the results of the command](#how-to-get-the-results-of-the-command)
22
+ * [The command function](#the-command-function)
23
+ * [The following are tools bundled with freeipmi](#the-following-are-tools-bundled-with-freeipmi)
24
+ * [To contrast ipmitool has one command with many options](#to-contrast-ipmitool-has-one-command-with-many-options)
25
+ * [Auto Detect workarounds](#auto-detect-workarounds)
26
+ * [Troubleshooting](#troubleshooting)
27
+ * [Log files](#log-files)
28
+ * [Diagnostics Function](#diagnostics-function)
29
+ * [Test Function](#test-function)
30
+ * [Contributing to rubyipmi](#contributing-to-rubyipmi)
31
+ * [Copyright](#copyright)
32
+ * [Freeipmi Documented Workarounds](#freeipmi-documented-workarounds)
33
+
1
34
  # Rubyipmi
2
35
  This gem is a ruby wrapper for the freeipmi and ipmitool command line tools.
3
36
  It provides a ruby implementation of ipmi commands that will make it simple to connect to BMC devices from ruby.
@@ -6,12 +39,37 @@ It provides a ruby implementation of ipmi commands that will make it simple to c
6
39
  [![Gem Version](https://badge.fury.io/rb/rubyipmi.png)](http://badge.fury.io/rb/rubyipmi)
7
40
  [![Coverage Status](https://coveralls.io/repos/logicminds/rubyipmi/badge.png)](https://coveralls.io/r/logicminds/rubyipmi)
8
41
 
42
+ Rubyipmi was built because I wanted an object oriented way to get data from BMC devices. I also wanted it easy to use
43
+ and if any IPMI hacks/workarounds were required I wanted to build those into the library to make life easier.
44
+
9
45
  ## Projects that use Rubyipmi
10
46
  * https://github.com/sensu/sensu-community-plugins/blob/master/plugins/ipmi/check-sensor.rb
11
- * https://github.com/theforeman/smart-proxy
12
- * https://github.com/logicminds/ipmispec
47
+ * https://github.com/theforeman/smart-proxy (Turns Rubyipmi into a Remote Web API Proxy server)
48
+ * https://github.com/logicminds/ipmispec (just started)
13
49
 
14
50
  Don't see your project listed? Create a PR with your project listed here.
51
+
52
+ ## Support
53
+ General support is offered via github issues and whenever I have time I will try to resolve any issues. I do offer
54
+ professional paid support through my [company](http://www.logicminds.biz) and can be contracted to work directly with your organization
55
+ on Rubyipmi or other related automation/devops projects that you might have.
56
+
57
+ At this time I only have one test server (HP DL380 G5) which I used to perform tests against. While I try to keep the code
58
+ generic in nature there may be newer devices that do not work correctly and its an issue I cannot troubleshoot directly. If you would
59
+ like to see newer/other devices be part of my test suite and you have extra servers lying around. I would encourage you to donate
60
+ server equipment so that I can extend my test suite against this newer equipment.
61
+
62
+ Servers I have never tested against.
63
+
64
+ * Dell
65
+ * IBM
66
+ * HP server with ilo3+
67
+ * Super Micro
68
+ * Cisco
69
+
70
+ IPMI is designed to support any equipment that implements the standard. But there are always problems with people deviating
71
+ from the standard. In general this library should work will all servers.
72
+
15
73
  ## Using the library in your code
16
74
 
17
75
  ### Requirements
@@ -20,39 +78,46 @@ Don't see your project listed? Create a PR with your project listed here.
20
78
  1. Install the freeipmi from source (http://www.gnu.org/software/freeipmi/) or ipmitool
21
79
  2. `gem install rubyipmi`
22
80
 
23
- #### Create a connection object
81
+ ### Create a connection object
24
82
 
25
83
  ```ruby
26
84
  require 'rubyipmi'
27
85
  conn = Rubyipmi.connect("username", "password", "hostname", "providertype")
28
-
29
86
  ```
30
87
 
31
- Providertype: optional (ipmitool or freeipmi)
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'
32
98
 
33
99
  If you don't specify the provider type, Rubyipmi will detect if freeipmi or ipmitool
34
100
  is installed and load the first tool found. If you specify the provider type rubyipmi will only use that specific
35
101
  provider.
36
102
 
37
- Additionally, if your using [openipmi](http://openipmi.sourceforge.net) and will be using rubyipmi to connect to the
38
- localhost you can utilize the openipmi driver and not have to pass in any connection parameters. Openipmi works
39
- by installing a driver and makes it available to the host. Freeipmi/Ipmitool will then try to use this driver to
40
- automatically use the openipmi if no host is given. The one caveat here is that you cannot control remote hosts using
41
- openipmi. The rubyipmi code must be executed on the host you want to control. The upside is that you don't need
42
- any credentials. Some commands may require root privileges to run when using openipmi.
43
-
103
+ You can specify additional options by passing an options hash into the connection method
44
104
  ```ruby
45
- conn = Rubyipmi.connect
46
- conn.power.status
105
+ conn = Rubyipmi.connect("username", "password", "hostname", 'freeipmi', {:privilege =>'USER', :driver => 'lan20'})
47
106
  ```
48
107
 
49
- Should you need to specify some additional options or the provider type
50
- ```ruby
51
- conn = Rubyipmi.connect(nil,nil,nil, 'freeipmi', {:privilege =>'USER'})
52
- ```
108
+ Privilege
53
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
54
112
 
55
- #### Use power functions (not all listed)
113
+ Driver
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
118
+
119
+
120
+ ### power functions
56
121
 
57
122
  ```ruby
58
123
  require 'rubyipmi'
@@ -65,18 +130,24 @@ Don't see your project listed? Create a PR with your project listed here.
65
130
 
66
131
  ```
67
132
 
68
- #### Boot to specific device
133
+ ### Boot to specific device
69
134
 
70
135
  ```ruby
71
136
  require 'rubyipmi'
72
137
  conn = Rubyipmi.connect("username", "password", "hostname")
73
- conn.chassis.bootpxe(true, false) # reboot after setting, one time boot only - non persistent
74
- conn.chassis.bootdisk(false, false) # boot to disk on next reboot, don't reboot automatically
75
-
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
76
147
  ```
77
148
 
78
149
 
79
- #### Sensors
150
+ ### Sensors
80
151
 
81
152
  ```ruby
82
153
  require 'rubyipmi'
@@ -87,7 +158,7 @@ Don't see your project listed? Create a PR with your project listed here.
87
158
 
88
159
  ```
89
160
 
90
- #### Fru
161
+ ### Fru
91
162
 
92
163
  ```ruby
93
164
  require 'rubyipmi'
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,48 @@
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
34
+ ### 0.10.0
35
+ * gh-26 - make the driver default to lan20
36
+
37
+ Users of older IPMI devices will now need to pass the specified driver type.
38
+
39
+ ### 0.9.3
40
+ * normalize the options being passed into the connect method
41
+
42
+ ### 0.9.2
43
+ * fixes an issue where is_provider_installed? should only return a boolean value instead of raising and error
44
+ * fixes a minor style issue where providers_installed? was returning an array when a boolean might have been expected
45
+
1
46
  ### 0.9.1
2
47
  * fixes an issue with connection_works? api call when command raises an error
3
48
 
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 |task, args|
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 ||= Array(ENV['ipmiprovider']) || ['freeipmi', 'ipmitool']
35
+ providers ||= Array(ENV['ipmiprovider']) || ['freeipmi', 'ipmitool']
62
36
 
63
- providers.each do | provider |
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 |t, args |
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, {:subject => subject})
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] ||= 'smtp.gmail.com'
103
- opts[:from_alias] ||= gmail_id
104
- opts[:subject] ||= @subject
105
- opts[:body] ||= data
106
- opts[:to] ||= to
107
- opts[:port] ||= 587
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,:login) do
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.9.1
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
- if not $?.success?
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 so we have to validate it with additional
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
- return process_status
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
- if result
97
- # The errorcode code hash contains the fix
98
- begin
99
- fix = ErrorCodes.search(result)
100
- @options.merge_notify!(fix)
101
- rescue
102
- Rubyipmi.logger.debug("Could not find fix for error code: \n#{result}") if logger
103
- raise "Could not find fix for error code: \n#{result}"
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
- @options.merge!(opts)
106
+ @options.merge!(opts)
110
107
  end
111
108
 
112
- # This method will check if the results are really valid as the exit code can be misleading and incorrect
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
- # override in child class if needed
115
- if ! exitstatus.success?
116
- raise "Error occurred"
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