2
0
mirror of https://opendev.org/x/pyghmi synced 2026-01-12 11:12:31 +00:00
Jan-Philipp Litza e2b2f6806b Refactor oemmap lookup
Previously, looking up an unknown OEM resulted in an exception being
logged:

exception while get_oem_handler, oemid:{'device_id': 32, 'device_revision': 1, 'manufacturer_id': 10876, 'product_id': 2414, 'firmware_version': '1.73'}
Traceback (most recent call last):
  File "/omd/sites/plutex/local/lib/python3/pyghmi/ipmi/oem/lookup.py", line 43, in get_oem_handler
    return (oemmap[oemid['manufacturer_id']].OEMHandler(oemid,
KeyError: 10876

So while I was at it, I also reduced duplicate code.

Signed-off-by: Jan-Philipp Litza <jpl@plutex.de>
Change-Id: Ib2483aeb3f92bcafbaa877eb1c0318a385f97474
2021-12-17 15:45:05 +01:00
2021-02-17 11:05:53 +01:00
2021-12-17 15:45:05 +01:00
2021-10-18 14:28:18 +02:00
2018-08-10 14:36:57 +02:00
2019-04-19 19:49:52 +00:00
2018-08-10 14:36:57 +02:00
2020-02-20 08:58:24 -05:00
2019-02-04 15:59:18 -05:00
2018-08-17 12:04:36 +02:00
2013-06-24 14:15:39 -04:00
2019-02-04 15:59:18 -05:00
2021-01-29 15:36:11 +00:00
2014-05-08 14:06:01 -04:00
2018-08-17 11:08:56 +02:00
2021-01-29 15:36:11 +00:00
2021-01-29 15:36:11 +00:00
2021-01-29 15:36:11 +00:00
2021-10-18 14:28:18 +02:00
2019-02-08 15:22:53 -05:00

pyghmi

Pyghmi is a pure Python (mostly IPMI) server management library.

Building and installing

(These instructions have been tested on CentOS 7)

Clone the repository, generate the RPM and install it:

$ git clone https://github.com/openstack/pyghmi.git
$ cd pyghmi/
$ python setup.py bdist_rpm
$ sudo rpm -ivh dist/pyghmi-*.noarch.rpm

Using

There are a few use examples in the bin folder:

  • fakebmc: simply fakes a BMC that supports a few IPMI commands (useful for testing)
  • pyghmicons: a remote console based on SOL redirection over IPMI
  • pyghmiutil: an IPMI client that supports a few direct uses of pyghmi (also useful for testing and prototyping new features)
  • virshbmc: a BMC emulation wrapper using libvirt

Extending

If you plan on adding support for new features, you'll most likely be interested in adding your methods to pyghmi/ipmi/command.py. See methods such as get_users and set_power for examples of how to use internal mechanisms to implement new features. And please, always document new methods.

Sometimes you may want to implement OEM-specific code. For example, retrieving firmware version information is not a part of standard IPMI, but some servers are known to support it via custom OEM commands. If this is the case, follow these steps:

  • Add your generic retrieval function (stub) to the OEMHandler class in pyghmi/ipmi/oem/generic.py. And please, document its intent, parameters and expected return values.
  • Implement the specific methods that your server supports in subdirectories in the oem folder (consider the lenovo submodule as an example). A OEM folder will contain at least one class inheriting from OEMHandler, and optionally helpers for running and parsing custom OEM commands.
  • Register mapping policies in pyghmi/ipmi/oem/lookup.py so pyghmi knows how to associate a BMC session with the specific OEM code you implemented.

A good way of testing the new feature is using bin/pyghmiutil. Just add an extension for the new feature you just implemented (as a new command) and call it from the command line:

$ IPMIPASSWORD=passw0rd bin/pyghmiutil [BMC IP address] username my_new_feature_command
Description
No description provided
Readme Apache-2.0 16 MiB
Languages
Python 99.9%
Shell 0.1%