kontron / python-ipmi Goto Github PK
View Code? Open in Web Editor NEWA pure python IPMI library
License: GNU Lesser General Public License v2.1
A pure python IPMI library
License: GNU Lesser General Public License v2.1
shell command:
ipmitool -I lanplus -H $hostname -U admin -P xxxxxx sensor
The document was not found.
How in the python implementation? thx ~
Would be nice to have classes to deal with:
Based on your example I made an created the following code:
`
def show_device_id(device_id):
"""
Function printing the result of the get_device_id() in the order
as presented in the IPMI 2.0 standard. The only exception is the
'Additional Device Support' which is placed at the end and shows
all possible functions marking with [X] which are supported.
"""
functions = (
('SENSOR', 'Sensor Device', 11),
('SDR_REPOSITORY', 'SDR Repository Device', 3),
('SEL', 'SEL Device', 14),
('FRU_INVENTORY', 'FRU Inventory Device', 4),
('IPMB_EVENT_RECEIVER', 'IPMB Event Receiver', 5),
('IPMB_EVENT_GENERATOR', 'IPMB Event Generator', 4),
('BRIDGE', 'Bridge', 18),
('CHASSIS', 'Chassis Device', 10))
ChkBox=['[ ]','[X]']
print('''\n
Device ID: %(device_id)s
Provides Device SDRs: %(provides_sdrs)s
Device Revision: %(revision)s
Device Available: %(available)d
Firmware Revision: %(fw_revision)s
IPMI Version: %(ipmi_version)s
Manufacturer ID: %(manufacturer_id)d (0x%(manufacturer_id)04x)
Product ID: %(product_id)d (0x%(product_id)04x)
Aux Firmware Rev Info: %(aux)s
Additional Device Support: '''[1:-1] % device_id.__dict__)
for n, s, l in functions:
if device_id.supports_function(n):
print(' %s%s%s' % (s,l*' ',ChkBox[1]))
else:
print(' %s%s%s' % (s,l*' ',ChkBox[0]))`
similarly I created another one:
`
def show_watchdog_timer(watchdog_timer):
"""
Function printing the result of the get_watchdog_timer().
"""
timer_use_const=['BIOS FRB2','BIOS/POST','OS Load','SMS/OS','OEM']
pretime_intr_const=['None','SMI','NMI','Msg intr']
timeout_act_const=['No action','Hard Reset','Power Down','Power Cycle']
print("""\n
Don't log: {0[dont_log]:}
Timer is running: {0[is_running]:}
Pre-timout interval: {0[pre_timeout_interval]:d}
Initial countdown value: {0[initial_countdown]:d}
Present countdown value: {0[present_countdown]:d}
"""[1:-1].format(watchdog.__dict__),end='')
print(" Timer use: ",
timer_use_const[watchdog.__dict__['timer_use']-1])
print(" Timer use expiration flag: ",
timer_use_const[watchdog_timer.__dict__['timer_use_expiration_flags']-1])
print(" Pre-timeout interrupt: ",
pretime_intr_const[watchdog.__dict__['pre_timeout_interval']])
print(" Time out action: ",
timeout_act_const[watchdog.__dict__['timeout_action']])`
Currently I am working on a third one, namely
def show_chassis_status(chassis_status):
So, probably we should create a new file where we collect all these functions. Of course, a more elegant solution would be to create a show' class which show method is inherited by the Ipmi class and based on the object type passed as an argument different method would be called. As an example, when you code you can do something like this
`
ipmi.show(device_id) # First function would be called
ipmi.show(watchdog_timer) # Second function would be called
ipmi.show(chassis_status) # Third function would be called`
What do you think?
BR/Ferenc
I don't know how to set the parameter of '-t' when I start a session to the IPM Ibackend. I have used the cmd like :
ipmitool -H x.x.x.x -I lanplus -U xxx -P xxxxxx power status
It dosen't incude '-t' and how to decide it.
Hope for help!
An exception is raised when SdrCommon.from_data() is called with an SDR record with type code 0xC0 (OEM).
I don't know how to get the IPMB, so, I use another issue code
interface = pyipmi.interfaces.create_interface('ipmitool', interface_type='lanplus')
connection = pyipmi.create_connection(interface)
connection.target = pyipmi.Target(0x20)
connection.target.set_routing([(0x20, 0)])
connection.session.set_session_type_rmcp(host_name, port=22)
connection.session.set_auth_type_user(user, password)
connection.session.establish()
connection.get_chassis_status()
Any in-progress or plan to include the native SOL feature with this module ?
example :
ipmitool -H <server> -U <id> -P <pass> -I lanplus sol activate
OR
This module already have this feature ? i unable find from wiki docs
Thanks
tests/test_bmc.py ... [ 1%]
tests/test_chassis.py . [ 1%]
tests/test_errors.py ........ [ 4%]
tests/test_fields.py ... [ 6%]
tests/test_fru.py ..FFF [ 8%]
tests/test_helper.py . [ 8%]
tests/test_hpm.py .......F [ 11%]
tests/test_ipmi.py ......... [ 15%]
tests/test_picmg.py ..... [ 17%]
tests/test_sdr.py ................ [ 24%]
tests/test_sel.py .. [ 25%]
tests/test_sensor.py . [ 25%]
tests/test_utils.py ............ [ 30%]
tests/interfaces/test_ipmb.py ........ [ 33%]
tests/interfaces/test_ipmitool.py ............. [ 39%]
tests/interfaces/test_rmcp.py ............... [ 45%]
tests/msgs/test_bmc.py ........ [ 48%]
tests/msgs/test_chassis.py .... [ 50%]
tests/msgs/test_device_messaging.py ............................. [ 62%]
tests/msgs/test_event.py .... [ 64%]
tests/msgs/test_fru.py ............... [ 70%]
tests/msgs/test_hpm.py ..... [ 72%]
tests/msgs/test_message.py ...... [ 74%]
tests/msgs/test_picmg.py ............. [ 80%]
tests/msgs/test_sdr.py ................ [ 86%]
tests/msgs/test_sel.py .... [ 88%]
tests/msgs/test_sensor.py ............................ [100%]
====================================================================== FAILURES ======================================================================
____________________________________________________________ test_fru_inventory_from_file ____________________________________________________________
def test_fru_inventory_from_file():
path = os.path.dirname(os.path.abspath(__file__))
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
fru = get_fru_inventory_from_file(fru_file)
tests/test_fru.py:32:
filename = '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
def get_fru_inventory_from_file(filename):
try:
file = open(filename, "rb")
except IOError:
print('Error open file "%s"' % filename)
################################
# get file size
file_size = os.stat(filename).st_size
E FileNotFoundError: [Errno 2] No such file or directory: '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
pyipmi/fru.py:99: FileNotFoundError
---------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------
Error open file "/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin"
__________________________________________________________________ test_board_area ___________________________________________________________________
def test_board_area():
path = os.path.dirname(os.path.abspath(__file__))
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
fru = get_fru_inventory_from_file(fru_file)
tests/test_fru.py:39:
filename = '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
def get_fru_inventory_from_file(filename):
try:
file = open(filename, "rb")
except IOError:
print('Error open file "%s"' % filename)
################################
# get file size
file_size = os.stat(filename).st_size
E FileNotFoundError: [Errno 2] No such file or directory: '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
pyipmi/fru.py:99: FileNotFoundError
---------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------
Error open file "/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin"
_________________________________________________________________ test_product_area __________________________________________________________________
def test_product_area():
path = os.path.dirname(os.path.abspath(__file__))
fru_file = os.path.join(path, 'fru_bin/kontron_am4010.bin')
fru = get_fru_inventory_from_file(fru_file)
tests/test_fru.py:51:
filename = '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
def get_fru_inventory_from_file(filename):
try:
file = open(filename, "rb")
except IOError:
print('Error open file "%s"' % filename)
################################
# get file size
file_size = os.stat(filename).st_size
E FileNotFoundError: [Errno 2] No such file or directory: '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin'
pyipmi/fru.py:99: FileNotFoundError
---------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------
Error open file "/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/fru_bin/kontron_am4010.bin"
_________________________________________________________________ test_upgrade_image _________________________________________________________________
def test_upgrade_image():
path = os.path.dirname(os.path.abspath(__file__))
hpm_file = os.path.join(path, 'hpm_bin/firmware.hpm')
image = UpgradeImage(hpm_file)
tests/test_hpm.py:94:
pyipmi/hpm.py:678: in init
self._from_file(filename)
self = <pyipmi.hpm.UpgradeImage object at 0x7fd08d5f3358>, filename = '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/hpm_bin/firmware.hpm'
def _from_file(self, filename):
try:
file = open(filename, "rb")
except IOError:
print('Error open file "%s"' % filename)
################################
# get file size
file_size = os.stat(filename).st_size
E FileNotFoundError: [Errno 2] No such file or directory: '/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/hpm_bin/firmware.hpm'
pyipmi/hpm.py:699: FileNotFoundError
---------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------
Error open file "/home/lbazan/rpmbuild/BUILD/python-ipmi-0.4.1/tests/hpm_bin/firmware.hpm"
================================================================== warnings summary ==================================================================
tests/msgs/test_message.py::TestMessage
cannot collect test class 'TestMessage' because it has a init constructor
-- Docs: http://doc.pytest.org/en/latest/warnings.html
================================================== 4 failed, 238 passed, 1 warnings in 3.69 seconds ==================================================
error: Bad exit status from /var/tmp/rpm-tmp.DMBEs1 (%check)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.DMBEs1 (%check)
Metadata-Version: 1.1
Name: python-ipmi
Version: 0.1.0
Author: UNKNOWN
Author-email: michael walle at kontron com
Home-page: https://github.com/kontron/python-ipmi
Download-url: UNKNOWN
Summary: Pure python IPMI library
License: LGPLv2+
Description: Pure Python IPMI Library
========================
|BuildStatus|
Features
--------
* RMCP interface (using ipmitool)
* IPMB interface (The `Total Phase`_ Aardvark)
Requirements
------------
You need an either the `ipmitool`_ for accessing RCMP interface or a
`Total Phase`_ Aardvark for communication over the IPMB interface.
Contributing
------------
Contributions are always welcome. You may send patches directly (eg. ``git
send-email``), do a github pull request or just file an issue.
* respect the coding style (eg. PEP8),
* provide well-formed commit message (see `this blog post
<http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_.)
* add a Signed-off-by line (eg. ``git commit -s``)
License
-------
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
.. _Total Phase: http://www.totalphase.com
.. _ipmitool: http://sourceforge.net/projects/ipmitool/
.. |BuildStatus| image:: https://travis-ci.org/kontron/python-ipmi.png?branch=master
:target: https://travis-ci.org/kontron/python-ipmi
.. |PyPiVersion| image:: https://badge.fury.io/py/python-ipmi.svg
:target: http://badge.fury.io/py/python-ipmi
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
With python-ipmi 0.1.0 I ran the following. "sipl_tm" is a custom interface I have added to communicate IPMI commands over a RS232 interface in TM (terminal mode) format.
python pyipmi\ipmitool.py -I sipl_tm fru print 0 all
Output:
<snip>
Multirecord Area:
Traceback (most recent call last):
File "pyipmi\ipmitool.py", line 575, in <module>
main()
File "pyipmi\ipmitool.py", line 478, in main
cmd(ipmi, args)
File "pyipmi\ipmitool.py", line 223, in cmd_fru_print
print ' %s' % record
File "C:\Users\paul.barker\Git\ca-ipmi-test\lib\pyipmi\fru.py", line 261, in __str__
return '%02x: %s' % (self.type,
AttributeError: FruPicmgRecord instance has no attribute 'type'
On line 261 of fru.py I can fix this issue by changing self.type to self.record_type_id and the resulting output makes sense. Is that the correct fix?
I have installed the "pip install pyipmi"
[root@5d6ffa863468 ~]# python
Python 2.7.7 (default, Jul 21 2015, 10:02:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import pyipmi
>>> import pyipmi.interfaces
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named interfaces
I have been working on making this work with python 3, and I believe I have been successful.
I have all tests passing, and the example in the readme + a few other variations have identical behavior in both python 2 & 3.
You can find the fork here https://github.com/Teslafly/python-ipmi
The thing is, this was fairly quick and dirty, (futureise & 2to3 + i/o fixes) and I have alternative (aka, custom) hardware / uses for this library, so am not able to test most interfaces / functionality.
If this can be tested, or reviewed in any way to make sure it actually works in the intended circumstances, that would be preferable to do before a pull.
Do you have any plans to provide -R
(retry) option?
-R retry Set the number of retries for lan/lanplus interface [default=4]
If ipmitool request to a hostname that does not exist, the following error occurs after about 5 seconds.
ipmitool
$ ipmitool -I lanplus -U user-P password -H 172.16.1.10 chassis status
Error: Unable to establish IPMI v2 / RMCP+ session
python-ipmi
ipmi.get_chassis_status()
Traceback (most recent call last):
File "ipmitool/ipmi.py", line 16, in <module>
device_id = ipmi.get_device_id()
File "pyipmi/bmc.py", line 25, in get_device_id
return DeviceId(self.send_message_with_name('GetDeviceId'))
File "pyipmi/init.py", line 206, in send_message_with_name
rsp = self.send_message(req)
File "pyipmi/init.py", line 190, in send_message
rsp = self.interface.send_and_receive(req)
File "pyipmi/interfaces/ipmitool.py", line 146, in send_and_receive
rsp_data = self.send_and_receive_raw(req.target, req.lun, req.netfn,
File "pyipmi/interfaces/ipmitool.py", line 119, in send_and_receive_raw
raise RuntimeError('ipmitool failed with rc=%d' % rc)
RuntimeError: ipmitool failed with rc=1
Since this time is too long, if i use the -R 1
option, an error is returned within 2 seconds.
$ ipmitool -I lanplus -U user -P password -H 172.16.1.10 chassis status -R 1
So, I want the following change.
https://github.com/kontron/python-ipmi/blob/0.4.2/pyipmi/interfaces/ipmitool.py#L187
...
cmd += (' -R "%d"' % 1) # '1' is example, to be variable
...
Do you agree to offer these options? If you agree, I will send you an MR.
While installing through pip in Python 2.6 got following error message:
(jjb_env)[manjunath@oc1275007250 ~]$ pip install python-ipmi
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting python-ipmi
/home/manjunath/jjb_env/lib/python2.6/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading python-ipmi-0.1.2.tar.gz (54kB)
100% |████████████████████████████████| 57kB 228kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/tmp/pip-build-2L4i46/python-ipmi/setup.py", line 11, in
version = subprocess.check_output(
AttributeError: 'module' object has no attribute 'check_output'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2L4i46/python-ipmi
Should give me proper message saying not supported on 2.6.! should block installing on python 2.6 if not supported.
Hello,
I was writing script which would pooling power usage from servers over IPMI and noticed that there is no DCIM section implemented in this module.
Hi Team,
I have installed Python-ipmi module with 2.7 version python, I am using Total Phase Aardvark and running an example to create IPMI Interface, so whenever run that I am getting an Pop up Error as Error while Initializing Driver.
But I could able to use Aardvark device though their Control phase application, it detects the Aardvark device and also able to use their Python API's to read the number of devices connected with port and serial number.
Could you anyone share details/comments on this issue?
I would like to create a IPMI connection using python-ipmi module with aardvark device and do read/write with IPMI supported device.
import pyipmi
import pyipmi.interfaces
interface = pyipmi.interfaces.create_interface(interface='ipmitool',
interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp('10.20.100.40', port=623)
ipmi.session.set_auth_type_user('admin', 'admin')
ipmi.target = pyipmi.Target(ipmb_address=0x82, routing=[(0x81,0x20,0),(0x20,0x82,7)])
ipmi.session.establish()
device_id = ipmi.get_device_id()
Response :
Traceback (most recent call last):
File "ipmitool.py", line 13, in
device_id = ipmi.get_device_id()
File "/usr/lib/python2.7/site-packages/pyipmi/bmc.py", line 25, in get_device_id
return DeviceId(self.send_message_with_name('GetDeviceId'))
File "/usr/lib/python2.7/site-packages/pyipmi/init.py", line 206, in send_message_with_name
rsp = self.send_message(req)
File "/usr/lib/python2.7/site-packages/pyipmi/init.py", line 190, in send_message
rsp = self.interface.send_and_receive(req)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 145, in send_and_receive
req_data.tostring())
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 117, in send_and_receive_raw
raise RuntimeError('ipmitool failed with rc=%d' % rc)
RuntimeError: ipmitool failed with rc=1
Is there a way to establish and keep a session open. What I understand is that each time an ipmitool command is run a new session is established with the BMC and your program does the same thing for each command issued to the BMC. But if ipmitool is run with the shell command it maintains one session open for all commands entered in the shell. Is such a thing possible with your tool? Thanks.
Hi ,
I've been trying to install version 0.2.2 on centos with python3.6 and getting following error :
"
Collecting robotframework-ipmilibrary==0.2.2 (from -r requirements.txt (line 67))
Downloading https://files.pythonhosted.org/packages/62/08/61f1cf31f50fa85089cc33408d92c6ad8e160c93c1a75d4a5ca0f53ac205/robotframework-ipmilibrary-0.2.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-l_f7aqpw/robotframework-ipmilibrary/setup.py", line 49
print "build_libdoc requires the Robot Framework package."
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("build_libdoc requires the Robot Framework package.")?
"
isn't this version of library suppose to work on python3.6?
import pyipmi
import pyipmi.interfaces
interface = pyipmi.interfaces.create_interface(interface='rmcp',
slave_address=0x81,
host_target_address=0x20,
keep_alive_interval=1)
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp(host='10.20.100.40', port=623)
ipmi.session.set_auth_type_user(username='admin', password='admin')
ipmi.target = pyipmi.Target(ipmb_address=0x20)
ipmi.session.establish()
device_id = ipmi.get_device_id()
Response:
File "rmcp.py", line 12, in
ipmi.session.establish()
File "/usr/lib/python2.7/site-packages/pyipmi/session.py", line 104, in establish
self.interface.establish_session(self)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/rmcp.py", line 456, in establish_session
self.ping()
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/rmcp.py", line 395, in ping
self._receive_asf_msg(AsfPong)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/rmcp.py", line 377, in receive_asf_msg
(, class_of_msg, data) = self._receive()
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/rmcp.py", line 342, in _receive
(pdu, _) = self._sock.recvfrom(4096)
socket.timeout: timed out
can't get fru info!
what's the error?
fru_info = connection.get_fru_inventory() File "build\bdist.win-amd64\egg\pyipmi\fru.py", line 92, in get_fru_inventory File "build\bdist.win-amd64\egg\pyipmi\fru.py", line 74, in read_fru_data File "build\bdist.win-amd64\egg\pyipmi\__init__.py", line 196, in send_message_with_name File "build\bdist.win-amd64\egg\pyipmi\__init__.py", line 181, in send_message File "build\bdist.win-amd64\egg\pyipmi\interfaces\ipmitool.py", line 136, in send_and_receive print('') File "build\bdist.win-amd64\egg\pyipmi\interfaces\ipmitool.py", line 112, in send_and_receive_raw print("LNC: %s" % t_lnc) RuntimeError: ipmitool failed with rc=1
Hi,
In the following code block:
def send_message(self, req):
req.target = self.target
req.requester = self.requester
retry = 3
while True:
retry -= 1
try:
rsp = self.interface.send_and_receive(req)
break
except CompletionCodeError as e:
if e.cc == msgs.constants.CC_NODE_BUSY:
retry -= 1
continue
return rsp
The "retry" variable is actually never checked. Also, If we get a CompletionCodeError when trying to call self.interface.send_and_receive, we substract one to the retry again even though we've only done a single attempt (but substracted 2 to the retry). If we consistently fail to complete the command, the while loop will never exit. Finally, "rsp" isn't initialized and the "continue" statement at the end of the code block is unecessary: the next line would automatically go to the next iteration of the while loop.
This can probably be fixed with something like that (not tested):
def send_message(self, req):
req.target = self.target
req.requester = self.requester
rsp = None
retry = 3
while retry > 0:
retry -= 1
try:
rsp = self.interface.send_and_receive(req)
break
except CompletionCodeError as e:
pass
return rsp
In refference to issue #24.
I've FINALLY had a bit of time to mess with this a little bit. Apologies for being so busy on other things.
I'm trying to figure out what the correct way to make an rmpc native connection is.
I've tried the following, but I can't seem to make the rmcp interface work.
interface = create_interface("rmcp")
interface.port = 623
interface.host = self.hostname
ipmi = pyipmi.create_connection(self.interface)
ipmi.session.set_auth_type_user(self.username, self.password)
ipmi.session.set_session_type_rmcp(self.hostname, port=623)
ipmi.target = pyipmi.Target(0x82)
# ipmi.target.set_routing([(0x81,0x20,0),(0x20,0x82,7)])
ipmi.get_chassis_status()
If we can get a quick start for rmcp going, I'll take some time to update the readme markdown on the front page.
I am packaging python-ipmi for Debian (see https://bugs.debian.org/969146) and it is strongly recommended that all binaries ship a man page. So please provide a man page for ipmitool.py. You could write the man page in reStructuredText and use pandoc to convert it into a man page.
Hi,
I am very glad that you made effort on putting this library together. I definitely would like to use it for gathering sensor and other info from the distance of our server designed by us . This feature would be useful for making predictive maintenance with machine learning in the future.
I am new to github, so I do not know how to contribute to this project (also my python knowledge is moderate only).
As a first step I want to contribute by writing a documentation for this library. I started writing in Word doc a few days ago, but I assume this is not the preferred format (maybe Jupyter Notebook?). While I am writing the doc I use mostly reverse engineering by reading your code (that is also a good exercise for knowing better python) and also with trial and error by using our servers for sending/receiving IPMI commands (I am also new to IPMI standard, so this is another area which I am learning).
Please, provide your feedback., what format shall be used for documenting the library. Meanwhile I attached what I did till now.
pyipmi_doc.docx
Regards,
Ferenc
Hello Guys, anyone would know what am I doing wrong?
Here's one of my servers:
$ ipmitool -H 10.8.1.18 -U root -P pass -I lanplus fru print 0
Board Mfg Date : Wed Oct 24 05:37:00 2018
Board Mfg : MYMFG
Board Product : MYBPD
Board Serial : MYBSN
Board Part Number : MYBPN
Product Manufacturer : MYMFG
Product Name : MYPPN
Product Version : 01
Product Serial : MYSER
Product Asset Tag : MYAST
Trying to deal with FRU in a script:
#!/bin/env python
import pyipmi
import pyipmi.interfaces
def main():
interface = pyipmi.interfaces.create_interface('ipmitool',
interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp('10.8.1.18', port=623)
ipmi.session.set_auth_type_user('root', 'pass')
ipmi.session.establish()
fru = ipmi.get_fru_inventory(0)
ipmi.session.close()
if __name__ == "__main__":
main()
but I get this error:
# python ./ipmi11.py
Traceback (most recent call last):
File "./ipmi11.py", line 18, in <module>
main()
File "./ipmi11.py", line 13, in main
fru = ipmi.get_fru_inventory()
File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 88, in get_fru_inventory
return FruInventory(self.read_fru_data(fru_id=fru_id))
File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 58, in read_fru_data
area_size = self.get_fru_inventory_area_info(fru_id)
File "/usr/lib/python2.7/site-packages/pyipmi/fru.py", line 35, in get_fru_inventory_area_info
fru_id=fru_id)
File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 206, in send_message_with_name
rsp = self.send_message(req)
File "/usr/lib/python2.7/site-packages/pyipmi/__init__.py", line 190, in send_message
rsp = self.interface.send_and_receive(req)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 147, in send_and_receive
req_data.tostring())
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 96, in send_and_receive_raw
cmd = self._build_ipmitool_cmd(target, lun, netfn, raw_bytes)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 205, in _build_ipmitool_cmd
cmd += self._build_ipmitool_target(target)
File "/usr/lib/python2.7/site-packages/pyipmi/interfaces/ipmitool.py", line 165, in _build_ipmitool_target
if target.routing is not None:
AttributeError: 'NoneType' object has no attribute 'routing'
Ideas? Thanks!
Hi!
So, I am trying to use the python module to get the health of my system using the sensors. So I have outragously took part of the code in ipmitool to have this sensors and their values. But on a supermicro server, I an error (sometimes it's a timeout, sometimes, an error). When I run the ipmitool, I got this:
$ ipmitool.py -I rmcp -H 10.65.xxx.xx -U ADMIN -P XXXXXX sdr list
SDR-ID | | Device String |
=======|=====|====================|====================
0x0004 | 1 | b'CPU1 Temp' | 40.0 | 0xc0
0x0047 | 2 | b'CPU2 Temp' | 42.0 | 0xc0
0x008a | 9 | b'Inlet Temp' | 22.0 | 0xc0
0x00cd | 11 | b'System Temp' | 31.0 | 0xc0
0x0110 | 12 | b'Peripheral Temp' | 48.0 | 0xc0
0x0153 | 16 | b'VRMCpu1 Temp' | 38.0 | 0xc0
0x0196 | 17 | b'VRMCpu2 Temp' | 37.0 | 0xc0
0x01d9 | 18 | b'VRMSoc1 Temp' | 45.0 | 0xc0
0x021c | 19 | b'VRMSoc2 Temp' | 38.0 | 0xc0
0x025f | 20 | b'VRMP1ABCD Temp' | 41.0 | 0xc0
0x02a2 | 21 | b'VRMP1EFGH Temp' | 41.0 | 0xc0
0x02e5 | 22 | b'VRMP2ABCD Temp' | 33.0 | 0xc0
0x0328 | 23 | b'VRMP2EFGH Temp' | 36.0 | 0xc0
0x036b | 176 | b'P1-DIMMA1 Temp' | 37.0 | 0xc0
0x03ae | 178 | b'P1-DIMMB1 Temp' | 37.0 | 0xc0
0x03f1 | 180 | b'P1-DIMMC1 Temp' | 37.0 | 0xc0
0x0434 | 182 | b'P1-DIMMD1 Temp' | 36.0 | 0xc0
0x0477 | 184 | b'P1-DIMME1 Temp' | 34.0 | 0xc0
0x04ba | 186 | b'P1-DIMMF1 Temp' | 34.0 | 0xc0
0x04fd | 188 | b'P1-DIMMG1 Temp' | 33.0 | 0xc0
0x0540 | 190 | b'P1-DIMMH1 Temp' | 33.0 | 0xc0
0x0583 | 208 | b'P2-DIMMA1 Temp' | 31.0 | 0xc0
0x05c6 | 210 | b'P2-DIMMB1 Temp' | 31.0 | 0xc0
0x0609 | 212 | b'P2-DIMMC1 Temp' | 31.0 | 0xc0
0x064c | 214 | b'P2-DIMMD1 Temp' | 30.0 | 0xc0
0x068f | 216 | b'P2-DIMME1 Temp' | 34.0 | 0xc0
0x06d2 | 218 | b'P2-DIMMF1 Temp' | 33.0 | 0xc0
0x0715 | 220 | b'P2-DIMMG1 Temp' | 33.0 | 0xc0
0x0758 | 222 | b'P2-DIMMH1 Temp' | 33.0 | 0xc0
0x079b | 65 | b'FAN1' | 8600.0 | 0xc0
0x07de | 66 | b'FAN2' | 8700.0 | 0xc0
Traceback (most recent call last):
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/ipmitool.py", line 188, in cmd_sdr_list
(value, states) = ipmi.get_sensor_reading(s.number)
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/sensor.py", line 164, in get_sensor_reading
lun=lun)
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/__init__.py", line 207, in send_message_with_name
check_completion_code(rsp.completion_code)
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/utils.py", line 47, in check_completion_code
raise CompletionCodeError(cc)
pyipmi.errors.CompletionCodeError: CompletionCodeError cc=0xcb desc=Requested data not present
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/rpelissi/venv/bin/ipmitool.py", line 11, in <module>
load_entry_point('python-ipmi==0.4.2', 'console_scripts', 'ipmitool.py')()
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/ipmitool.py", line 593, in main
cmd(ipmi, args)
File "/home/rpelissi/venv/lib64/python3.6/site-packages/pyipmi/ipmitool.py", line 207, in cmd_sdr_list
e.cc))
TypeError: unsupported format string passed to bytes.__format__
Any idea on how I can debug this? I am not too familiar with ipmi but if I can give you more infos, just let me know!
Thanks again for this code!
When using the latest version from git, python-ipmi fails on Ubuntu 20.04. Relevant code snippet:
interface = pyipmi.interfaces.create_interface(interface='ipmitool', interface_type='lanplus')
ipmi = pyipmi.create_connection(interface)
ipmi.session.set_session_type_rmcp(host=fqdn, port=port)
ipmi.session.set_auth_type_user(username=username, password=password)
ipmi.target = pyipmi.Target()
ipmi.session.establish()
ipmi_info = ipmi.get_device_id()
Traceback (most recent call last):
File "example.py", line 7
ipmi_info = ipmi.get_device_id()
File "/usr/lib/python3/dist-packages/pyipmi/bmc.py", line 25, in get_device_id
return DeviceId(self.send_message_with_name('GetDeviceId'))
File "/usr/lib/python3/dist-packages/pyipmi/__init__.py", line 206, in send_message_with_name
rsp = self.send_message(req)
File "/usr/lib/python3/dist-packages/pyipmi/__init__.py", line 190, in send_message
rsp = self.interface.send_and_receive(req)
File "/usr/lib/python3/dist-packages/pyipmi/interfaces/ipmitool.py", line 147, in send_and_receive
py3_array_tobytes(req_data))
File "/usr/lib/python3/dist-packages/pyipmi/utils.py", line 57, in py3_array_tobytes
return msg.tobytes()
AttributeError: 'ByteBuffer' object has no attribute 'tobytes'
Hi,
I'm looking at using python-ipmi in some software development and it would be good to be using a released version rather than just the HEAD of the master branch. Do you have any plans to make a release with a version number?
Thanks,
Paul
The result of command "ipmitool xxx sel list" are raw log, how to realize the "sel elist" result ? Thanks.
and this value is hardcoded.
i'm getting errors in pkg installation in virtual environment:
python setup.py install
venv/lib/python3.6/site-packages/setuptools/dist.py:407: UserWarning: The version specified ('0.4.0-33-g3943149') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
"details." % self.metadata.version
byte-compiling build/bdist.linux-x86_64/egg/pyipmi/version.py to version.cpython-36.pyc
File "build/bdist.linux-x86_64/egg/pyipmi/version.py", line 2
version = 'b'0.4.0-33-g3943149''
^
SyntaxError: invalid syntax
Extracting python_ipmi-0.4.0_33_g3943149-py3.6.egg to venv/lib/python3.6/site-packages
File "venv/lib/python3.6/site-packages/python_ipmi-0.4.0_33_g3943149-py3.6.egg/pyipmi/version.py", line 2
version = 'b'0.4.0-33-g3943149''
^
SyntaxError: invalid syntax
i also get this errors in installation using pip
Hi, i would like to know if it is possible to use this library as a IPMC. So i can emulate IPMC and test it with this library as well for development for both IPMC and ChassisManager.
virtual_env_3_7/lib64/python3.7/site-packages/pyipmi/msgs/message.py:371: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
return data.tostring()
virtual_env_3_7/lib64/python3.7/site-packages/pyipmi/interfaces/ipmitool.py:144: DeprecationWarning: fromstring() is deprecated. Use frombytes() instead.
req_data.push_string(encode_message(req))
virtual_env_3_7/lib64/python3.7/site-packages/pyipmi/interfaces/ipmitool.py:147: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
req_data.tostring())
virtual_env_3_7/lib64/python3.7/site-packages/pyipmi/msgs/message.py:367: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
return data.tostring()
kindly add support for FRU editing ipmitool.py
I am running Ubuntu 18.04 in WSL if that matters.
I downloaded the python-ipmi tarball and ran setup.py to install python-ipmi.
Hello guys!
Any docs/examples for a python newbie? ;) Tnx.
Ran 245 tests in 1.112s
FAILED (errors=94)
RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.84h9mv (%check)
Bad exit status from /var/tmp/rpm-tmp.84h9mv (%check)
Child return code was: 1
EXCEPTION: [Error()]
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 93, in trace
result = func(*args, **kw)
File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 739, in do_with_status
raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed:
Hi,
In 2016 an issue was opened #13 for this which you closed with the comment:
It is fixed by adding "optional".
I do not understand where is that 'optional' field defined?
Here is what I have tried with our server:
Called the low level method:
chasstatus=ipmi.send_message_with_name('GetChassisStatus')
And with:
chasstatus.__dict__
get the result:
{'completion_code': 0, 'current_power_state': <pyipmi.msgs.message.Bitfield.BitWrapper at 0x22af7cb5c18>, 'data': '', 'front_panel_button_capabilities': 112, 'last_power_event': <pyipmi.msgs.message.Bitfield.BitWrapper at 0x22af7cb5c88>, 'lun': 0, 'misc_chassis_state': <pyipmi.msgs.message.Bitfield.BitWrapper at 0x22af7cb57f0>}
If I am calling the high level method:
chassis_status=ipmi.get_chassis_status()
then for:
chassis_status.__dict__
get this:
{'control_fault': False, 'fault': False, 'interlock': False, 'overload': False, 'power_on': True, 'restore_policy': 2}
There is no 'optional' attribute. If I ask for the optional fields:
'{0:08b}'.format(int(chasstatus.misc_chassis_state))
then got this:
'01000000'
which indicates chassis identify cmd and info supported by the server.
I looked through your code in Chassys.py but I could not find this optional attribute.
Regards,
Ferenc
How to used get_lan_configuration_parameters get lan onfig info?
I found channel is the 1 second parmater is 5(LAN_PARAMETER_MAC_ADDRESS)
set_selector block_selector which number fill it?
thanks
ipmitool -I lanplus -H 172.16.0.11 -U root -P Huawei12#$ lan print 1
The interface given will shell out to ipmitool meaning that:
Why not create a udp connection that speaks RMCP+ and a set of interfacing functions to conduct logic?
From the ipmi 2.0 spec, 28.2 Get Chassis Status Command, there is an optional extra byte in response data. So the response could be 5 bytes. But GetChassisStatusRsp handles 4 bytes only, which will raise DecodingError('Data has extra bytes'). I have came across this problem on some HP servers, they returned the optional byte as 0x00.
I am not familiar with the source code, maybe appending a RemainingBytes to GetChassisStatusRsp will solve the issue?
The current version of pyipmi
on PyPI is 0.4.2, but since October 2020 there is a 0.5.0 release tag on this github repository. Will this version be released on PyPI, and if so, is there a time indication for this?
Как пользоваться этой хуетой, нихуя не работает.
connection.get_fru_inventory() fails to parse the payload:
/home/mark/venvs/snmp/local/lib/python2.7/site-packages/pyipmi/fru.pyc in _from_data(self,
data)
286 self.length = data[2]
287 if sum(data[:5]) % 256 != 0:
--> 288 raise DecodingError('FruDataMultiRecord header checksum failed')
289 self.raw = data[5:5+self.length]
290 if (sum(self.raw) + data[3]) % 256 != 0:
DecodingError: FruDataMultiRecord header checksum failed
The FRU Data:
In [9]: connection.read_fru_data()
Out[9]: '\x01\x00\x01\x06\x14\x01\x00\xe3\x01\x05\x17\xcb1S1QUZZ0STW\xcdQTFCPY823000A\xc6Quanta\xc1\x00\x00\xd8\x01\x0e\x19\x05\x0f\xb4\xdcQuanta Cloud Technology Inc.\xd4SD1Q-1ULH-6 cores MB\xcbGPY82000008\xcb31S1QMB0060\xc9FRU v0.10\xcdS1Q_00_QCT_00\xc3N/A\xc1\x00\x003\x01\x0b\x19\xc6Qumulo\xccQK-Series 1U\xd195-10B01-01 rev01\xc31.0\xccS0501825Q007\xc0\xc9FRU v0.10\xc3N/A\xc3N/A\xc3N/A\xc1\x00\x00\x00\x00\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
This fru data parses with ipmitool:
FRU Device Description : Builtin FRU Device (ID 0)
Chassis Type : Rack Mount Chassis
Chassis Part Number : 1S1QUZZ0STW
Chassis Serial : QTFCPY823000A
Chassis Extra : Quanta
Board Mfg Date : Fri Jun 8 16:05:00 2018
Board Mfg : Quanta Cloud Technology Inc.
Board Product : SD1Q-1ULH-6 cores MB
Board Serial : GPY82000008
Board Part Number : 31S1QMB0060
Board Extra : S1Q_00_QCT_00
Board Extra : N/A
Product Manufacturer : Qumulo
Product Name : QK-Series 1U
Product Part Number : 95-10B01-01 rev01
Product Version : 1.0
Product Serial : S0501825Q007
Product Extra : N/A
Product Extra : N/A
Product Extra : N/A
It's registered on PyPI but nothing has been uploaded.
'import pyipmi' works for my in python 2.7
It fails for me in python 3.4:
Traceback (most recent call last):
File "src/hello.py", line 1, in <module>
import pyipmi
File "...\pyipmi\__init__.py", line 174
except CompletionCodeError, e:
^
SyntaxError: invalid syntax
Is python 3 supported? If not could you update the readme to indicate this so that it's clear to new users of this library.
Thanks!
I use install ipmi tools and it's availibe with command :
it's directed by kernel module:
modprobe ipmi_devintf
modprobe ipmi_si
root@myserver:~# ipmitool sel info
SEL Information
Version : 1.5 (v1.5, v2 compliant)
Entries : 20
Free Space : 704 bytes
Percent Used : 31%
Last Add Time : 06/10/2019 09:37:05
Last Del Time : 01/13/2012 09:04:19
Overflow : false
Supported Cmds : 'Reserve'
Hot to use python-ipmi, no network lan or etc ... just direct call to kernel ipmi on /dev/ipmi0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.