While receiving the SDR, when the size is uneven, its division by 2
causes it to become a float instead of an integer, leading to a
TypeError later on:
Traceback (most recent call last):
File "gipmi/sdr.py", line 634, in __init__
self.read_info()
File "gipmi/sdr.py", line 665, in read_info
self.get_sdr()
File "gipmi/sdr.py", line 740, in get_sdr
sdrrec = self.ipmicmd.raw_command(netfn=0x0a, command=0x23,
File "gipmi/command.py", line 500, in raw_command
rsp = self.ipmi_session.raw_command(netfn=netfn, command=command,
File "gipmi/private/session.py", line 779, in raw_command
self._send_ipmi_net_payload(netfn, command, data,
File "gipmi/private/session.py", line 819, in _send_ipmi_net_payload
data = bytearray(data)
TypeError: 'float' object cannot be interpreted as an integer
Change-Id: I3e123487b27ef385823b1a20652195c7588f5d6c
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 IPMIpyghmiutil: 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
OEMHandlerclass inpyghmi/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
oemfolder (consider thelenovosubmodule as an example). A OEM folder will contain at least one class inheriting fromOEMHandler, and optionally helpers for running and parsing custom OEM commands. - Register mapping policies in
pyghmi/ipmi/oem/lookup.pyso 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