diff --git a/bin/pyghmiutil b/bin/pyghmiutil index 0a7b8211..5d94ab05 100755 --- a/bin/pyghmiutil +++ b/bin/pyghmiutil @@ -72,6 +72,8 @@ def docommand(result, ipmisession): print repr(led) elif cmmand == 'graphical': print ipmisession.get_graphical_console() + elif cmmand == 'net': + print ipmisession.get_net_configuration() elif cmmand == 'raw': print ipmisession.raw_command(netfn=int(args[0]), command=int(args[1]), diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index ce4bb2cf..29df0546 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -748,6 +748,8 @@ class Command(object): retdata['ipv4_backup_gateway'] = self._fetch_lancfg_param(channel, 14) retdata['ipv4_backup_gateway_mac'] = self._fetch_lancfg_param(channel, 15) + self.oem_init() + self._oem.add_extra_net_configuration(retdata) return retdata def get_sensor_data(self): diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 9db559f9..2ee1690f 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -212,3 +212,12 @@ class OEMHandler(object): def get_graphical_console(self): """Get graphical console launcher""" return () + + def add_extra_net_configuration(self, netdata): + """Add additional network configuration data + + Given a standard netdata struct, add details as relevant from + OEM commands, modifying the passed dictionary + :param netdata: Dictionary to store additional network data + """ + return diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index dce6bf4f..ae628649 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -15,6 +15,7 @@ # limitations under the License. import base64 +import binascii import traceback import urllib @@ -38,6 +39,8 @@ from pyghmi.ipmi.oem.lenovo import raid_drive import pyghmi.util.webclient as wc +import socket + inventory.register_inventory_category(cpu) inventory.register_inventory_category(dimm) inventory.register_inventory_category(pci) @@ -521,3 +524,21 @@ class OEMHandler(generic.OEMHandler): return self._get_ts_remote_console(self.ipmicmd.bmc, self.ipmicmd.ipmi_session.userid, self.ipmicmd.ipmi_session.password) + + def add_extra_net_configuration(self, netdata): + if self.has_tsm: + ipv6_addr = self.ipmicmd.xraw_command( + netfn=0x0c, command=0x02, + data=(0x01, 0xc5, 0x00, 0x00))["data"][1:] + if not ipv6_addr: + return + ipv6_prefix = ord(self.ipmicmd.xraw_command( + netfn=0xc, command=0x02, + data=(0x1, 0xc6, 0, 0))['data'][1]) + if hasattr(socket, 'inet_ntop'): + ipv6str = socket.inet_ntop(socket.AF_INET6, ipv6_addr) + else: + # fall back to a dumber, but more universal formatter + ipv6str = binascii.b2a_hex(ipv6_addr) + ipv6str = ':'.join([ipv6str[x:x+4] for x in xrange(0, 32, 4)]) + netdata['ipv6_address'] = '{0}/{1}'.format(ipv6str, ipv6_prefix)