mirror of
https://opendev.org/x/pyghmi
synced 2025-01-13 11:17:47 +00:00
Add support for OEM command for IPv6 address fetch
Prior to IPv6 being pulled into the proper specification, there were OEM commands to implement it. Pull in the AMI OEM version for systems with TSMs present. Change-Id: I137887fc57a3daa652f1e0a1bd50a806d3e42b13
This commit is contained in:
parent
78d95b8afb
commit
69266bc95f
@ -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]),
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user