|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import sys |
| 4 | + |
| 5 | +import pyipmi |
| 6 | +import pyipmi.interfaces |
| 7 | + |
| 8 | +host = sys.argv[1] |
| 9 | +user = sys.argv[2] |
| 10 | +password = sys.argv[3] |
| 11 | + |
| 12 | +intf = pyipmi.interfaces.create_interface('rmcp+') |
| 13 | + |
| 14 | +sess = pyipmi.Session() |
| 15 | +sess.set_session_type_rmcp(host, 623) |
| 16 | +sess.set_auth_type_user(user, password) |
| 17 | +target = pyipmi.Target(ipmb_address=0x20) |
| 18 | + |
| 19 | +# (1) The device connection can either be opened and closed |
| 20 | +ipmi = pyipmi.Ipmi(interface=intf, session=sess, target=target) |
| 21 | +ipmi.open() |
| 22 | +device_id = ipmi.get_device_id() |
| 23 | +ipmi.close() |
| 24 | + |
| 25 | +# (2) or the 'with' statement can be used |
| 26 | +with pyipmi.Ipmi(interface=intf, session=sess, target=target) as ipmi: |
| 27 | + device_id = ipmi.get_device_id() |
| 28 | + |
| 29 | +print(''' |
| 30 | +Device ID: %(device_id)s |
| 31 | +Device Revision: %(revision)s |
| 32 | +Firmware Revision: %(fw_revision)s |
| 33 | +IPMI Version: %(ipmi_version)s |
| 34 | +Manufacturer ID: %(manufacturer_id)d (0x%(manufacturer_id)04x) |
| 35 | +Product ID: %(product_id)d (0x%(product_id)04x) |
| 36 | +Device Available: %(available)d |
| 37 | +Provides SDRs: %(provides_sdrs)d |
| 38 | +Additional Device Support: |
| 39 | +'''[1:-1] % device_id.__dict__) |
| 40 | + |
| 41 | +functions = ( |
| 42 | + ('SENSOR', 'Sensor Device'), |
| 43 | + ('SDR_REPOSITORY', 'SDR Repository Device'), |
| 44 | + ('SEL', 'SEL Device'), |
| 45 | + ('FRU_INVENTORY', 'FRU Inventory Device'), |
| 46 | + ('IPMB_EVENT_RECEIVER', 'IPMB Event Receiver'), |
| 47 | + ('IPMB_EVENT_GENERATOR', 'IPMB Event Generator'), |
| 48 | + ('BRIDGE', 'Bridge'), |
| 49 | + ('CHASSIS', 'Chassis Device') |
| 50 | +) |
| 51 | +for n, s in functions: |
| 52 | + if device_id.supports_function(n): |
| 53 | + print(' %s' % s) |
| 54 | + |
| 55 | +if device_id.aux is not None: |
| 56 | + print('Aux Firmware Rev Info: [%s]' % ( |
| 57 | + ' '.join('0x%02x' % d for d in device_id.aux))) |
0 commit comments