rubyipmi 0.12.1 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f4f084aa7f49cb5e387e91beb0d0e3127de0c03bf320f49c0ebbb3134c0e37c
4
- data.tar.gz: 23e6a5dd885284aa9c2806b6ae7196f8d03fbf7009a72b9b89a66cd9a7e9e0b8
3
+ metadata.gz: 3c77f389e3e5f24be0a5176bd3a02c510e0d4ade7be804a955ae0e6237e64f9d
4
+ data.tar.gz: 32771f70ef680b8d9a1cd0dd08a815abff60bd0c3a64d5971a0b858086a50ff5
5
5
  SHA512:
6
- metadata.gz: 7d7b1f5a620e693dbbc013d80311c45496e9fa49494ed90b936b7e17bc9084123b5951878962ab53738ef484b4bda2d737afa13b9461d7fdf634913022acaabd
7
- data.tar.gz: 809ac56808cc4183461e6722224220a64be4904940aa7eef59a94abccdcf4a750ecb031c83ec706b4206f0ecc8e60272e1fd3f8d637bca7ec93b5c1100111a4c
6
+ metadata.gz: 72fb59a9cd489faa8aec2218ceca97b7bb6e012989253838b0bf766da478d5c1ebdf2a5689d7038f6f56810aca7ec45f52358b55a0c5e9b77a2a23847c651949
7
+ data.tar.gz: a530de8260fcd287b22be9c31934d4ae7457fe19e97368ff3d02f2c14029fb104ecbbbda018ea818de23b80a7d4f9f87963632da902fd22a71532ffd8be8c23e
data/CHANGELOG.md CHANGED
@@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased] - 0.12.1
8
+ ## [Unreleased]
9
+
10
+ ## [0.13.0]
11
+ - Drop support for testing ruby 2.x #66
12
+ - Adds experimental testing support for ruby 4.0
13
+ - Fixes: CVE-2026-0980 @evgeni
14
+
15
+ ## [0.12.1] - 2026
9
16
 
10
17
  ### Fixed
11
18
  - Don't re-raise the original exception in basecommand
data/README.md CHANGED
@@ -1,464 +1,434 @@
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
-
34
1
  # Rubyipmi
35
- This gem is a ruby wrapper for the freeipmi and ipmitool command line tools.
36
- It provides a ruby implementation of ipmi commands that will make it simple to connect to BMC devices from ruby.
37
2
 
38
- [![Build Status](https://travis-ci.org/logicminds/rubyipmi.png)](https://travis-ci.org/logicminds/rubyipmi)
39
- [![Gem Version](https://badge.fury.io/rb/rubyipmi.png)](http://badge.fury.io/rb/rubyipmi)
40
- [![Coverage Status](https://coveralls.io/repos/logicminds/rubyipmi/badge.png)](https://coveralls.io/r/logicminds/rubyipmi)
3
+ A Ruby library for controlling and querying BMC (Baseboard Management Controller) devices. Rubyipmi wraps the **freeipmi** and **ipmitool** command-line tools behind a consistent, object-oriented API so you can drive IPMI from Ruby scripts, monitoring tools, or automation without shelling out or parsing CLI output yourself.
41
4
 
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.
5
+ ---
44
6
 
45
- ## Projects that use Rubyipmi
46
- * https://github.com/sensu-plugins/sensu-plugins-ipmi
47
- * https://github.com/theforeman/smart-proxy (Turns Rubyipmi into a Remote Web API Proxy server)
48
- * https://github.com/logicminds/ipmispec (just started)
7
+ ## Table of Contents
49
8
 
50
- Don't see your project listed? Create a PR with your project listed here.
9
+ - [Requirements](#requirements)
10
+ - [Installation](#installation)
11
+ - [Quick Start](#quick-start)
12
+ - [Usage Scenarios](#usage-scenarios)
13
+ - [Connection options](#connection-options)
14
+ - [Power control](#power-control)
15
+ - [Boot device and PXE](#boot-device-and-pxe)
16
+ - [Sensors and monitoring](#sensors-and-monitoring)
17
+ - [FRU (Field Replaceable Unit) info](#fru-field-replaceable-unit-info)
18
+ - [BMC info and diagnostics](#bmc-info-and-diagnostics)
19
+ - [Development](#development)
20
+ - [Running tests](#running-tests)
21
+ - [Extending the library](#extending-the-library)
22
+ - [Troubleshooting](#troubleshooting)
23
+ - [Security](#security)
24
+ - [Projects using Rubyipmi](#projects-using-rubyipmi)
25
+ - [Support](#support)
26
+ - [Contributing](#contributing)
27
+ - [License](#license)
28
+ - [FreeIPMI workarounds](#freeipmi-documented-workarounds)
51
29
 
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.
30
+ ---
56
31
 
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.
32
+ ## Requirements
61
33
 
62
- Servers I have never tested against.
34
+ - **Ruby** 3.0+
35
+ - One of:
36
+ - [freeipmi](https://www.gnu.org/software/freeipmi/) (from source or package), or
37
+ - **ipmitool**
63
38
 
64
- * Dell
65
- * IBM
66
- * HP server with ilo3+
67
- * Super Micro
68
- * Cisco
39
+ Rubyipmi auto-detects which provider is installed. You can also force a specific provider (see [Connection options](#connection-options)).
69
40
 
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.
41
+ ---
72
42
 
73
- ## Using the library in your code
43
+ ## Installation
74
44
 
75
- ### Requirements
45
+ Add to your Gemfile:
76
46
 
47
+ ```ruby
48
+ gem 'rubyipmi'
49
+ ```
77
50
 
78
- 1. Install the freeipmi from source (http://www.gnu.org/software/freeipmi/) or ipmitool
79
- 2. `gem install rubyipmi`
51
+ Then:
80
52
 
81
- ### Create a connection object
53
+ ```bash
54
+ bundle install
55
+ ```
82
56
 
83
- ```ruby
84
- require 'rubyipmi'
85
- conn = Rubyipmi.connect("username", "password", "hostname", "providertype")
86
- ```
57
+ Or install globally:
87
58
 
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.
59
+ ```bash
60
+ the 
localhostgem install rubyipmi
61
+ Openipmi works
by installing a driver and makes it available to the host. Freeipmi/Ipmitool will then try to use```
94
62
 
95
- Providertype: optional
63
+ ---
96
64
 
97
- valid options: 'auto', 'ipmitool', 'freeipmi'
65
+ ## Quick Start
98
66
 
99
- If you don't specify the provider type, Rubyipmi will detect if freeipmi or ipmitool
100
- is installed and load the first tool found. If you specify the provider type rubyipmi will only use that specific
101
- provider.
67
+ ```ruby
68
+ require 'rubyipmi'
102
69
 
103
- You can specify additional options by passing an options hash into the connection method
104
- ```ruby
105
- conn = Rubyipmi.connect("username", "password", "hostname", 'freeipmi', {:privilege =>'USER', :driver => 'lan20'})
106
- ```
70
+ # Connect (provider is auto-detected: freeipmi or ipmitool)
71
+ conn = Rubyipmi.connect("username", "password", "hostname")
107
72
 
108
- Privilege
73
+ # Verify connectivity
74
+ conn.connection_works? # => true/false
109
75
 
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
76
+ # Power
77
+ conn.chassis.power.on?
78
+ conn.chassis.power.off
79
+ conn.chassis.power.on
80
+ conn.chassis.power.cycle
112
81
 
113
- Driver
82
+ # Sensors
83
+ conn.sensors.names
84
+ conn.sensors.list
114
85
 
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
86
+ # FRU (serial, model, etc.)
87
+ conn.fru.list
88
+ conn.fru.serial
89
+ conn.fru.manufacturer
90
+ conn.fru.product
118
91
 
92
+ # BMC info
93
+ conn.bmc.info
94
+ conn.bmc.version
95
+ ```
119
96
 
120
- ### power functions
97
+ ---
121
98
 
122
- ```ruby
123
- require 'rubyipmi'
124
- conn = Rubyipmi.connect("username", "password", "hostname")
125
- conn.chassis.power.on
126
- conn.chassis.power.off
127
- conn.chassis.power.on?
128
- conn.chassis.power.off?
129
- conn.chassis.power.cycle
99
+ ## Usage Scenarios
130
100
 
131
- ```
101
+ ### Connection options
132
102
 
133
- ### Boot to specific device
103
+ **Basic connection** (auto-detect provider):
134
104
 
135
- ```ruby
136
- require 'rubyipmi'
137
- conn = Rubyipmi.connect("username", "password", "hostname")
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
147
- ```
105
+ ```ruby
106
+ conn = Rubyipmi.connect("username", "password", "192.168.1.10")
107
+ ```
148
108
 
109
+ **Choose provider explicitly** (`'auto'`, `'freeipmi'`, or `'ipmitool'`):
149
110
 
150
- ### Sensors
111
+ ```ruby
112
+ conn = Rubyipmi.connect("username", "password", "192.168.1.10", "freeipmi")
113
+ ```
151
114
 
152
- ```ruby
153
- require 'rubyipmi'
154
- conn = Rubyipmi.connect("username", "password", "hostname")
155
- conn.sensors.names
156
- conn.sensors.list
157
- conn.sensors.<sensor name>
115
+ **Extra options** (privilege, driver):
158
116
 
159
- ```
117
+ ```ruby
118
+ conn = Rubyipmi.connect("username", "password", "192.168.1.10", "freeipmi", {
119
+ privilege: 'ADMINISTRATOR',
120
+ driver: 'lan20' # or 'lan15', 'auto', 'open'
121
+ })
122
+ ```
160
123
 
161
- ### Fru
124
+ **Local host with OpenIPMI** (no credentials; run on the same host as the BMC):
162
125
 
163
- ```ruby
164
- require 'rubyipmi'
165
- conn = Rubyipmi.connect("username", "password", "hostname")
166
- conn.fru.list
167
- conn.fru.serial
168
- conn.fru.manufacturer
169
- conn.fru.product
126
+ ```ruby
127
+ # Uses openipmi driver; no username/password/host needed
128
+ conn = Rubyipmi.connect(nil, nil, "localhost", "freeipmi", { driver: 'open' })
129
+ ```
170
130
 
171
- ```
131
+ Valid `privilege` values: `'CALLBACK'`, `'USER'`, `'OPERATOR'`, `'ADMINISTRATOR'`.
132
+ Valid `driver` values: `'auto'`, `'lan15'`, `'lan20'`, `'open'`.
172
133
 
173
- ## Testing
174
- There are a series of automated rspec tests that test the functionality of this library with the ipmi device.
175
- In order to perform use the following steps.
134
+ ---
176
135
 
177
- DO NOT PERFORM THESE TEST ON ANY PRODUCTION SYSTEM. THESE TESTS WILL TURN OFF THE DEVICE!
136
+ ### Power control
178
137
 
138
+ ```ruby
139
+ conn = Rubyipmi.connect(user, pass, host)
179
140
 
180
- 1. Install gem via source
181
- 2. bundle install
182
- 3. rake (runs unit tests, does not require a ipmi device)
183
- 3. rake integration ipmiuser=ipmiuser ipmipass=ipmiuserpass ipmihost=192.168.1.22 ipmiprovider=freeipmi (fill in your your details)
184
- 4. report any failures with your make/model/firmware revision to corey@logicminds.biz
141
+ conn.chassis.power.on # power on
142
+ conn.chassis.power.off # power off
143
+ conn.chassis.power.cycle # power cycle
144
+ conn.chassis.power.on? # => true if on
145
+ conn.chassis.power.off? # => true if off
146
+ ```
185
147
 
186
- ## Security
187
- The only security used throughout the library is the use of temporary password files that store the password while
188
- the command is being executed. This password file is created and deleted on the fly with every library call.
189
- The password will not be shown in any logs or process lists due to this enhancement. The filename is a long random string
190
- as is the folder name so it would be difficult to guess the password file. If for some reason a command takes a long
191
- time to run anyone could get the location of the file but the file is 0600 so it should not be readable by anyone outside
192
- of the process.
148
+ ---
193
149
 
150
+ ### Boot device and PXE
194
151
 
195
- ## How the library works
196
- Since this library is based off of running a suite of command line tools I have created a base class called baseCommand
197
- that performs the actual execution of the command. The baseCommand only executes the command with the supplied
198
- arguments and options and returns the exit status. Additionally the result of the executed command is stored in
199
- the result variable should we need to retrieve the output of the command. To further extend the baseCommand class.
152
+ Set next boot device and optionally reboot. Methods take `(reboot, persistent)`:
200
153
 
154
+ ```ruby
155
+ conn = Rubyipmi.connect(user, pass, host)
201
156
 
202
- ### Creating a new command
203
- Creating a new command is actually quite simple. Follow these steps to wrap a freeipmi or ipmitool command.
157
+ # PXE once, then revert to normal boot (reboot now)
158
+ conn.chassis.bootpxe(true, false)
204
159
 
205
- 1. Create a new subclass of BaseCommand
206
- 2. define the initialize function like so, and pass in the name of the command line tool to the super constructor.
160
+ # PXE on next reboot only (no reboot now)
161
+ conn.chassis.bootpxe(false, false)
207
162
 
208
- ```ruby
209
- def initialize(opts = {})
210
- @options = opts
211
- super("bmc-info", opts)
212
- end
163
+ # Boot from disk once, with immediate reboot
164
+ conn.chassis.bootdisk(true, false)
213
165
 
214
- ```
166
+ # Boot from disk from now on (persistent)
167
+ conn.chassis.bootdisk(true, true)
215
168
 
216
- ```ruby
217
- def initialize(opts = {})
218
- @options = opts
219
- super("ipmitool", opts)
220
- end
169
+ # CDROM
170
+ conn.chassis.bootcdrom(true, false)
171
+ ```
221
172
 
222
- ```
223
- 3. Thats it. The rest of the class is related to running the command and interperting the results
173
+ `reboot`: perform a power cycle after setting the boot device.
174
+ `persistent`: keep the boot device across reboots (otherwise one-time).
224
175
 
225
- ### Writing a function for running a command
226
- The freeipmi command line tools have two different ways to run the commands.
176
+ ---
227
177
 
228
- 1. ``` ipmipower --hostname=host --password=pass --username=user --off ``` (single action, multiple arguments)
229
- 2. ``` ipmi-chassis --hostname=host --password=pass --username=user --chassis-identify=FORCE ``` (multiple arguments, one main action with different qualifers)
178
+ ### Sensors and monitoring
230
179
 
231
- Because of the varying ways to run a command I have simplified them so it makes it easy to call the command line tools.
180
+ Useful for monitoring stacks (e.g. Sensu, Prometheus exporters):
232
181
 
233
- 1. Each subclassed baseCommand class inherits runcmd, result, cmd, and runcmd_with_args.
234
- 2. The cmd executable gets set when instantiating a baseCommand class, where the class also finds the path of the executable.
235
- 3. The options variable gets set when instantiating a subclass of the baseCommand class.
182
+ ```ruby
183
+ conn = Rubyipmi.connect(user, pass, host)
236
184
 
237
- ### Running the cmd
185
+ # List sensor names
186
+ conn.sensors.names
238
187
 
239
- 1. To run the cmd, just call ``` runcmd ``` (which will automatically set all the options specified in the options hash)
240
- 2. To run the cmd, with arguments and options call ``` runcmd([]) ``` and pass in a array of the arguments. (Arguments are actions only and look like --off, --on, --action)
241
- 3. To run the cmd, with just arguments ``` runcmd_with_args([]) ``` and pass in a array of the arguments. (Example: 192.168.1.1)
188
+ # Full sensor list (array of sensor data)
189
+ conn.sensors.list
242
190
 
243
- ### The Options hash
244
- The options hash can be considered a global hash that is passed in through the connection object.
245
- Most of the options will be set at the connection level. However, most commands require additional options
246
- that should be set at the subclassed BaseCommand level. You must not forget to unset the option after calling
247
- the runcmd command. Failure to do so will add previous options to subsequent run options.
191
+ # Access a sensor by normalized name (underscores, no spaces/dots)
192
+ conn.sensors.temperature_cpu1
193
+ conn.sensors.fan_speed_1
194
+ ```
248
195
 
249
- Example:
196
+ Example: collect temperatures for a custom monitor:
250
197
 
251
198
  ```ruby
252
- def ledlight(status=false, delay=300)
253
- if status
254
- if delay <= 0
255
- options["chassis-identify"] = "FORCE"
256
- else
257
- options["chassis-identify"] = delay
258
- end
259
- else
260
- options["chassis-identify"] = "TURN-OFF"
261
- end
262
- # Run the command
263
- run
264
- # unset the option by deleting from hash
265
- options.delete("chassis-identify")
199
+ conn.sensors.list.each do |sensor|
200
+ next unless sensor[:name].to_s.include?('temp')
201
+ puts "#{sensor[:name]}: #{sensor[:value]} #{sensor[:unit]}"
266
202
  end
267
-
268
203
  ```
269
204
 
270
- ### How to get the results of the command
271
- After running a command it may be desirable to get the results for further processing.
272
- Note that there are two kinds of results.
273
- 1. the text returned from the shell command, this is stored in @results
274
- 2. the status value returned from the shell command (true or false only) this is returned from runcmd.
205
+ ---
275
206
 
276
- To get the results:
207
+ ### FRU (Field Replaceable Unit) info
277
208
 
278
- Example:
209
+ Serial numbers, product names, manufacturers:
279
210
 
280
211
  ```ruby
212
+ conn = Rubyipmi.connect(user, pass, host)
281
213
 
282
- def status
283
- value = command("--stat")
284
- if value == true
285
- @result.split(":").last.chomp.trim
286
- end
287
- end
214
+ conn.fru.list # full FRU data
215
+ conn.fru.serial # serial number(s)
216
+ conn.fru.manufacturer # manufacturer
217
+ conn.fru.product # product name
218
+ ```
288
219
 
289
- def command(opt)
290
- status = run([opt])
291
- return status
292
- end
220
+ Handy for asset tracking or automation that needs to identify hardware.
293
221
 
294
- def on?
295
- status == "on"
296
- end
222
+ ---
297
223
 
298
- ```
224
+ ### BMC info and diagnostics
299
225
 
300
- ### The command function
301
- Although its not necessary to implement the command function it may be desirable if your code starts to repeat itself.
302
- In this example the command function is just a wrapper command that calls run. Your implementation will vary,
303
- but be sure to always call it the "command" function, so its easily identified.
304
- Additionally, should this gem ever become out of date one could call the command function and pass in any
305
- arguments that have not already been implemented in the rest of the class.
226
+ **BMC info and version:**
306
227
 
307
228
  ```ruby
229
+ conn.bmc.info
230
+ conn.bmc.version
231
+ ```
308
232
 
309
- def command(opt)
310
- status = runcmd([opt])
311
- return status
312
- end
313
-
314
- def on
315
- command("--on")
316
- end
233
+ **Connection check** (single place to validate credentials/host):
317
234
 
235
+ ```ruby
236
+ if conn.connection_works?
237
+ # proceed with power, sensors, etc.
238
+ else
239
+ # handle unreachable or bad credentials
240
+ end
318
241
  ```
319
242
 
320
- ## The following are tools bundled with freeipmi
243
+ **Generate a diagnostics file** (for bug reports or vendor-specific issues):
321
244
 
322
- * ipmi-chassis
323
- * ipmi-oem
324
- * ipmi-chassis-config
325
- * ipmiping
326
- * ipmiconsole
327
- * ipmipower
328
- * ipmidetect
329
- * ipmi-raw
330
- * ipmi-fru
331
- * ipmi-sel
332
- * ipmi-locate
333
- * ipmi-sensors
334
- * ipmimonitoring
335
- * ipmi-sensors-config
336
- * bmc-config
337
- * bmc-device
338
- * bmc-info
245
+ ```ruby
246
+ require 'rubyipmi'
247
+ Rubyipmi.get_diag(user, pass, host)
248
+ # Writes: /tmp/rubyipmi_diag_data.txt
249
+ # Review for sensitive data (IP/MAC, etc.) before sharing.
250
+ ```
339
251
 
340
- ## To contrast ipmitool has one command with many options
341
- * ipmitool
252
+ With debug logging:
342
253
 
254
+ ```ruby
255
+ require 'rubyipmi'
256
+ require 'logger'
257
+ Rubyipmi.log_level = Logger::DEBUG
258
+ Rubyipmi.get_diag(user, pass, host)
259
+ # Also creates /tmp/rubyipmi.log with commands run
260
+ ```
343
261
 
262
+ ---
344
263
 
345
- ## Auto Detect workarounds
346
- IPMI is great for a vendor neutral management interface. However, not all servers are 100% compatible with the specifications.
347
- In order to overcome ipmi non-compliance there will be some workarounds built into this library
264
+ ## Development
348
265
 
349
- ## Troubleshooting
266
+ ### Running tests
350
267
 
351
- ### Log files
352
- Rubyipmi has a built in logging system for debugging purposes. By default logging is disabled. The logger is a class instance
353
- variable and will stay in memory for as long as your program or interpreter is loaded. In order to enable logging
354
- you need to do the following.
268
+ **Unit tests** (no BMC required; mocks only):
355
269
 
356
- ```ruby
357
- require 'rubyipmi'
358
- require 'logger'
359
- Rubyipmi.log_level = Logger::DEBUG
270
+ ```bash
271
+ bundle install
272
+ bundle exec rake unit
360
273
  ```
361
- This will create a log file in /tmp/rubyipmi.log which you can use to trace the commands Rubyipmi generates and runs.
362
274
 
363
- If you want to setup a custom logger (not required) you can also pass in a logger instance as well.
275
+ **Integration tests** (require a real BMC; **they will power off/cycle the device**):
364
276
 
365
- ```ruby
366
- require 'rubyipmi'
367
- require 'logger'
368
- custom_logger = Logger.new('/var/log/rubyipmi_custom.log')
369
- custom_logger.progname = 'Rubyipmi'
370
- custom_logger.level = Logger::DEBUG
371
- Rubyipmi.logger = custom_logger
277
+ Do **not** run on production systems.
278
+
279
+ ```bash
280
+ bundle exec rake integration \
281
+ ipmiuser=USER \
282
+ ipmipass=PASS \
283
+ ipmihost=192.168.1.10 \
284
+ ipmiprovider=freeipmi
372
285
  ```
373
286
 
374
- ### Diagnostics Function
375
- Running IPMI commands can be frustrating sometimes and with the addition of this library you are bound to find edge
376
- cases. If you do find an edge case there is a easy function that will generate a diagnostics file that you can
377
- review and optionally create an issue with us to work with. Without this information its really hard to help because
378
- every server is different. The following code will generate a file in /tmp/rubyipmi_diag_data.txt that we can use
379
- as test cases. Please look over the file for any sensitive data you don't want to share like ip/mac address.
287
+ **Vagrant-based integration** (if you use the spec Vagrant setup):
380
288
 
381
- ```ruby
382
- require 'rubyipmi'
383
- Rubyipmi.get_diag(user, pass, host)
289
+ ```bash
290
+ cd spec && vagrant up && vagrant provision
291
+ vagrant ssh -c "/rubyipmi/rake integration ipmiuser=... ipmipass=... ipmihost=... ipmiprovider=freeipmi"
384
292
  ```
385
293
 
386
- You can couple this with the logger and also generate a log file of all the commands get_diag uses as well.
294
+ **CI:** The repo uses GitHub Actions; see `.github/workflows/test.yml`. Typical flow: checkout Ruby 3.x `bundle install` `bundle exec rake unit` → `gem build`.
295
+
296
+ ---
297
+
298
+ ### Extending the library
299
+
300
+ Rubyipmi runs the underlying CLI tools via a small command layer. To add or wrap new behavior:
301
+
302
+ 1. **Subclass the provider’s BaseCommand**
303
+ Use `Rubyipmi::Freeipmi::Commands::BaseCommand` or `Rubyipmi::Ipmitool::Commands::BaseCommand`.
304
+
305
+ 2. **Initialize with the executable name** (e.g. freeipmi’s `bmc-info` or `ipmitool`):
306
+
307
+ ```ruby
308
+ def initialize(opts = {})
309
+ @options = opts
310
+ super("bmc-info", opts) # or "ipmitool" for ipmitool
311
+ end
312
+ ```
313
+
314
+ 3. **Use the shared execution helpers**
315
+ - `runcmd` – run with current `options` (e.g. hostname, username, password).
316
+ - `runcmd(["--option"])` – run with extra arguments.
317
+ - `runcmd_with_args([...])` – run with only the given args.
318
+ - `@result` holds stdout; the return value of `runcmd` is the command success (true/false).
319
+
320
+ 4. **Options hash**
321
+ Connection options (host, user, password, driver, privilege) are in `options`. Add command-specific keys for that run, then **delete them after** so they don’t leak into the next command:
322
+
323
+ ```ruby
324
+ def some_action
325
+ options["chassis-identify"] = "FORCE"
326
+ runcmd
327
+ options.delete("chassis-identify")
328
+ end
329
+ ```
330
+
331
+ 5. **Expose the new command from the Connection**
332
+ In `lib/rubyipmi/freeipmi/connection.rb` (or ipmitool equivalent), add an accessor and instantiate your command class with `@options`.
333
+
334
+ **Freeipmi** uses many separate binaries (e.g. `ipmi-chassis`, `ipmi-sensors`, `bmc-info`). **Ipmitool** uses a single `ipmitool` binary with subcommands. Implement the appropriate BaseCommand and wire it into the connection object.
335
+
336
+ ---
337
+
338
+ ## Troubleshooting
339
+
340
+ ### Logging
341
+
342
+ By default, logging is disabled. To trace commands and options:
387
343
 
388
344
  ```ruby
389
- require 'rubyipmi'
390
- require 'logger'
391
- Rubyipmi.log_level = Logger::DEBUG
392
- Rubyipmi.get_diag(user, pass, host)
345
+ require 'rubyipmi'
346
+ require 'logger'
347
+ Rubyipmi.log_level = Logger::DEBUG
348
+ # Log file: /tmp/rubyipmi.log
393
349
  ```
394
350
 
395
- ### Test Function
396
- If you need to test if the bmc device and run a basic call there is now a function that retruns boolean true when
397
- the connection attempt was successful.
351
+ Custom logger:
398
352
 
399
353
  ```ruby
400
- require 'rubyipmi'
401
- conn = Rubyipmi.connect(user, pass, host)
402
- conn.connection_works? => true|false
354
+ custom = Logger.new('/var/log/rubyipmi.log')
355
+ custom.progname = 'Rubyipmi'
356
+ custom.level = Logger::DEBUG
357
+ Rubyipmi.logger = custom
403
358
  ```
404
359
 
405
- ## Contributing to rubyipmi
406
-
407
- * Check out the latest code to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
408
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
409
- * Fork the project.
410
- * Start a feature/bugfix branch.
411
- * Commit and push until you are happy with your contribution.
412
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
413
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
360
+ ### Diagnostics
414
361
 
415
- ## Copyright
362
+ For support or bug reports, generate a diagnostics file and (after redacting) attach it:
416
363
 
417
- Copyright (c) 2015 Corey Osman. See LICENSE.txt for
418
- further details.
364
+ ```ruby
365
+ Rubyipmi.get_diag(user, pass, host)
366
+ # Edit /tmp/rubyipmi_diag_data.txt to remove sensitive data, then share.
367
+ ```
419
368
 
369
+ ### Connection test
420
370
 
421
- ## Freeipmi Documented Workarounds
371
+ ```ruby
372
+ conn = Rubyipmi.connect(user, pass, host)
373
+ conn.connection_works? # => true/false
374
+ ```
422
375
 
376
+ ---
423
377
 
424
- One of my design goals is to raise exceptions and have the library try workarounds before ultimately failing since there is a whole list of workarounds that can be attempted.However, it would be nice to know the make and model of the server up front to decrease workaround attempts.
378
+ ## Security
425
379
 
426
- So essentially I need to figure out how to save a command call and then retry if it doesn't work.
380
+ Credentials are not passed on the command line. The library uses temporary files (mode `0600`) to pass passwords to the underlying CLI tools; files are created and removed around each call. Filenames and directory names are randomized to avoid guessing. Passwords do not appear in process listings or in logs.
427
381
 
428
- With so many different vendors implementing their own IPMI solutions, different vendors may implement their IPMI protocols incorrectly. The following describes a number of workarounds currently available to handle discovered compliance issues. When possible, workarounds have been implemented so they will be transparent to the user. However, some will require the user to specify a workaround be used via the -W option.
429
- The hardware listed below may only indicate the hardware that a problem was discovered on. Newer versions of hardware may fix the problems indicated below. Similar machines from vendors may or may not exhibit the same problems. Different vendors may license their firmware from the same IPMI firmware developer, so it may be worthwhile to try workarounds listed below even if your motherboard is not listed.
382
+ ---
430
383
 
431
- If you believe your hardware has an additional compliance issue that needs a workaround to be implemented, please contact the FreeIPMI maintainers on <freeipmi-users@gnu.org> or <freeipmi-devel@gnu.org>.
384
+ ## Projects using Rubyipmi
432
385
 
433
- assumeio - This workaround flag will assume inband interfaces communicate with system I/O rather than being memory-mapped. This will work around systems that report invalid base addresses. Those hitting this issue may see "device not supported" or "could not find inband device" errors. Issue observed on HP ProLiant DL145 G1.
386
+ - [sensu-plugins-ipmi](https://github.com/sensu-plugins/sensu-plugins-ipmi) IPMI checks for Sensu
387
+ - [smart-proxy](https://github.com/theforeman/smart-proxy) – Foreman Smart Proxy (exposes Rubyipmi as a remote API)
388
+ - [ipmispec](https://github.com/logicminds/ipmispec)
434
389
 
435
- spinpoll - This workaround flag will inform some inband drivers (most notably the KCS driver) to spin while polling rather than putting the process to sleep. This may significantly improve the wall clock running time of tools because an operating system scheduler's granularity may be much larger than the time it takes to perform a single IPMI message transaction. However, by spinning, your system may be performing less useful work by not contexting out the tool for a more useful task.
390
+ If you use Rubyipmi in a project, open a PR to add it to this list.
436
391
 
437
- authcap - This workaround flag will skip early checks for username capabilities, authentication capabilities, and K_g support and allow IPMI authentication to succeed. It works around multiple issues in which the remote system does not properly report username capabilities, authentication capabilities, or K_g status. Those hitting this issue may see "username invalid", "authentication type unavailable for attempted privilege level", or "k_g invalid" errors. Issue observed on Asus P5M2/P5MT-R/RS162-E4/RX4, Intel SR1520ML/X38ML, and Sun Fire 2200/4150/4450 with ELOM.
392
+ ---
438
393
 
439
- idzero - This workaround flag will allow empty session IDs to be accepted by the client. It works around IPMI sessions that report empty session IDs to the client. Those hitting this issue may see "session timeout" errors. Issue observed on Tyan S2882 with M3289 BMC.
394
+ ## Support
440
395
 
441
- unexpectedauth - This workaround flag will allow unexpected non-null authcodes to be checked as though they were expected. It works around an issue when packets contain non-null authentication data when they should be null due to disabled per-message authentication. Those hitting this issue may see "session timeout" errors. Issue observed on Dell PowerEdge 2850,SC1425. Confirmed fixed on newer firmware.
396
+ - **Community:** Open a [GitHub issue](https://github.com/logicminds/rubyipmi/issues) for bugs or feature requests.
397
+ - **Paid support:** [LogicMinds](http://www.logicminds.biz) offers professional support and custom development.
442
398
 
443
- forcepermsg - This workaround flag will force per-message authentication to be used no matter what is advertised by the remote system. It works around an issue when per-message authentication is advertised as disabled on the remote system, but it is actually required for the protocol. Those hitting this issue may see "session timeout" errors. Issue observed on IBM eServer 325.
399
+ Test coverage is limited to the hardware available to the maintainers (e.g. HP DL380 G5). IPMI is vendor-neutral, but implementations vary. Devices not regularly tested include Dell, IBM, HP iLO3+, Supermicro, Cisco. If you hit vendor-specific issues, diagnostics (see above) and FreeIPMI workarounds (below) often help.
444
400
 
445
- endianseq - This workaround flag will flip the endian of the session sequence numbers to allow the session to continue properly. It works around IPMI 1.5 session sequence numbers that are the wrong endian. Those hitting this issue may see "session timeout" errors. Issue observed on some Sun ILOM 1.0/2.0 (depends on service processor endian).
401
+ ---
446
402
 
447
- intel20 - This workaround flag will work around several Intel IPMI 2.0 authentication issues. The issues covered include padding of usernames, and password truncation if the authentication algorithm is HMAC-MD5-128. Those hitting this issue may see "username invalid", "password invalid", or "k_g invalid" errors. Issue observed on Intel SE7520AF2 with Intel Server Management Module (Professional Edition).
403
+ ## Contributing
448
404
 
449
- supermicro20 - This workaround flag will work around several Supermicro IPMI 2.0 authentication issues on motherboards w/ Peppercon IPMI firmware. The issues covered include handling invalid length authentication codes. Those hitting this issue may see "password invalid" errors. Issue observed on Supermicro H8QME with SIMSO daughter card. Confirmed fixed on newerver firmware.
405
+ 1. Check existing issues and PRs to avoid duplicate work.
406
+ 2. Fork the repo and create a feature or bugfix branch.
407
+ 3. Add tests for new behavior (unit tests for logic, integration only when needed).
408
+ 4. Keep Rakefile, version, and history changes minimal; if necessary, isolate in a single commit.
409
+ 5. Open a pull request with a clear description of the change.
450
410
 
451
- sun20 - This workaround flag will work work around several Sun IPMI 2.0 authentication issues. The issues covered include invalid lengthed hash keys, improperly hashed keys, and invalid cipher suite records. Those hitting this issue may see "password invalid" or "bmc error" errors. Issue observed on Sun Fire 4100/4200/4500 with ILOM. This workaround automatically includes the "opensesspriv" workaround.
411
+ ---
452
412
 
453
- opensesspriv - This workaround flag will slightly alter FreeIPMI's IPMI 2.0 connection protocol to workaround an invalid hashing algorithm used by the remote system. The privilege level sent during the Open Session stage of an IPMI 2.0 connection is used for hashing keys instead of the privilege level sent during the RAKP1 connection stage. Those hitting this issue may see "password invalid", "k_g invalid", or "bad rmcpplus status code" errors. Issue observed on Sun Fire 4100/4200/4500 with ILOM, Inventec 5441/Dell Xanadu II, Supermicro X8DTH, Supermicro X8DTG, Intel S5500WBV/Penguin Relion 700, Intel S2600JF/Appro 512X, and Quanta QSSC-S4R//Appro GB812X-CN. This workaround is automatically triggered with the "sun20" workaround.
413
+ ## License
454
414
 
455
- integritycheckvalue - This workaround flag will work around an invalid integrity check value during an IPMI 2.0 session establishment when using Cipher Suite ID 0. The integrity check value should be 0 length, however the remote motherboard responds with a non-empty field. Those hitting this issue may see "k_g invalid" errors. Issue observed on Supermicro X8DTG, Supermicro X8DTU, and Intel S5500WBV/Penguin Relion 700, and Intel S2600JF/Appro 512X.
415
+ Copyright (c) 2015 Corey Osman. See [LICENSE.txt](LICENSE.txt) for details (LGPL-2.1).
456
416
 
457
- No IPMI 1.5 Support - Some motherboards that support IPMI 2.0 have been found to not support IPMI 1.5. Those hitting this issue may see "ipmi 2.0 unavailable" or "connection timeout" errors. This issue can be worked around by using IPMI 2.0 instead of IPMI 1.5 by specifying --driver-address=LAN_2_0. Issue observed on HP Proliant DL 145.
417
+ ---
458
418
 
459
- slowcommit - This workaround will slow down commits to the BMC by sleeping one second between the commit of sections. It works around motherboards that have BMCs that can be overwhelmed by commits. Those hitting this issue may see commit errors or commits not being written to the BMC. Issue observed on Supermicro H8QME.
419
+ ## FreeIPMI documented workarounds
460
420
 
461
- veryslowcommit - This workaround will slow down commits to the BMC by sleeping one second between the commit of every key. It works around motherboards that have BMCs that can be overwhelmed by commits. Those hitting this issue may see commit errors or commits not being written to the BMC. Issue observed on Quanta S99Q/Dell FS12-TY.
421
+ Many vendors implement IPMI with quirks. FreeIPMI documents workarounds (e.g. `-W intel20`, `-W supermicro20`). Rubyipmi may expose or use some of these; for the full list and `-W` options, see the [FreeIPMI documentation](https://www.gnu.org/software/freeipmi/). If you need a workaround not yet supported, opening an issue with your BMC model and the FreeIPMI workaround that works on the CLI can help.
462
422
 
423
+ Common workaround flags (refer to FreeIPMI for current details):
463
424
 
425
+ - **assumeio** – inband I/O (e.g. HP ProLiant DL145 G1).
426
+ - **authcap** – skip early auth capability checks (e.g. Asus, Intel, Sun).
427
+ - **intel20** – Intel IPMI 2.0 auth (e.g. Intel SE7520AF2).
428
+ - **supermicro20** – Supermicro IPMI 2.0 (e.g. H8QME).
429
+ - **sun20** / **opensesspriv** – Sun/ILOM auth and session handling.
430
+ - **idzero**, **unexpectedauth**, **forcepermsg**, **endianseq** – session and auth quirks on various Dell, IBM, Tyan, Sun.
431
+ - **No IPMI 1.5 support** – use driver `lan20` (e.g. HP ProLiant DL145).
432
+ - **slowcommit** / **veryslowcommit** – BMCs that need slower config commits (e.g. Supermicro, Quanta/Dell).
464
433
 
434
+ Hardware listed is where issues were first seen; newer firmware may fix them. Similar or licensed firmware from other vendors may behave the same. To request new workarounds in FreeIPMI, contact [freeipmi-users](https://www.gnu.org/software/freeipmi/) or [freeipmi-devel](https://www.gnu.org/software/freeipmi/).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.1
1
+ 0.13.0
@@ -66,7 +66,7 @@ module Rubyipmi
66
66
  logger.debug(makecommand) if logger
67
67
  begin
68
68
  command = makecommand
69
- @lastcall = command.to_s
69
+ @lastcall = command
70
70
  @result, @result_err, status = Rubyipmi.capture3(command)
71
71
  # sometimes the command tool does not return the correct result, validate it with additional code
72
72
  process_status = validate_status(status)
@@ -25,9 +25,9 @@ module Rubyipmi::Freeipmi
25
25
  else
26
26
  "--#{k}=#{v}"
27
27
  end
28
- end.join(" ")
28
+ end
29
29
 
30
- "#{cmd} #{args.rstrip}"
30
+ [cmd] + args.compact
31
31
  end
32
32
 
33
33
  # This method will check if the results are really valid as the exit code can be misleading and incorrect
@@ -15,19 +15,19 @@ module Rubyipmi::Ipmitool
15
15
  end
16
16
 
17
17
  def makecommand
18
- args = ''
18
+ args = []
19
19
  # need to format the options to ipmitool format
20
20
  @options.each do |k, v|
21
21
  # must remove from command line as its handled via conf file
22
22
  next if k == "P"
23
23
  next if k == "cmdargs"
24
- args << " -#{k} #{v}"
24
+ args += ["-#{k}", v]
25
25
  end
26
26
 
27
27
  # since ipmitool requires commands to be in specific order
28
- args << ' ' + options.fetch('cmdargs', '')
28
+ args += options.fetch('cmdargs', '').split
29
29
 
30
- "#{cmd} #{args.lstrip}"
30
+ [cmd] + args.compact
31
31
  end
32
32
 
33
33
  # The findfix method acts like a recursive method and applies fixes defined in the errorcodes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubyipmi
4
- VERSION = '0.12.1'.freeze
4
+ VERSION = '0.13.0'.freeze
5
5
  end
data/lib/rubyipmi.rb CHANGED
@@ -147,7 +147,7 @@ module Rubyipmi
147
147
 
148
148
  # test-friendly capture3
149
149
  def self.capture3(cmd)
150
- return Open3.capture3(cmd)
150
+ return Open3.capture3(*cmd)
151
151
  end
152
152
 
153
153
  # method used to find the command which also makes it easier to mock with
data/rubyipmi.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency 'logger'
26
26
  s.add_development_dependency 'rspec'
27
27
  s.add_development_dependency 'rdoc', "~> 6.1"
28
- s.add_development_dependency 'bundler', "~> 2.0"
28
+ s.add_development_dependency 'bundler', ">= 2.0"
29
29
  s.add_development_dependency 'highline', '>= 1.0', '< 3'
30
30
  s.add_development_dependency 'rake', '~> 13'
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyipmi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
@@ -69,14 +69,14 @@ dependencies:
69
69
  name: bundler
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2.0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '2.0'
82
82
  - !ruby/object:Gem::Dependency