Skip to content

Commit 69266bc

Browse files
committed
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
1 parent 78d95b8 commit 69266bc

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

bin/pyghmiutil

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def docommand(result, ipmisession):
7272
print repr(led)
7373
elif cmmand == 'graphical':
7474
print ipmisession.get_graphical_console()
75+
elif cmmand == 'net':
76+
print ipmisession.get_net_configuration()
7577
elif cmmand == 'raw':
7678
print ipmisession.raw_command(netfn=int(args[0]),
7779
command=int(args[1]),

pyghmi/ipmi/command.py

+2
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ def get_net_configuration(self, channel=None):
748748
retdata['ipv4_backup_gateway'] = self._fetch_lancfg_param(channel, 14)
749749
retdata['ipv4_backup_gateway_mac'] = self._fetch_lancfg_param(channel,
750750
15)
751+
self.oem_init()
752+
self._oem.add_extra_net_configuration(retdata)
751753
return retdata
752754

753755
def get_sensor_data(self):

pyghmi/ipmi/oem/generic.py

+9
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,12 @@ def set_oem_domain_name(self, name):
212212
def get_graphical_console(self):
213213
"""Get graphical console launcher"""
214214
return ()
215+
216+
def add_extra_net_configuration(self, netdata):
217+
"""Add additional network configuration data
218+
219+
Given a standard netdata struct, add details as relevant from
220+
OEM commands, modifying the passed dictionary
221+
:param netdata: Dictionary to store additional network data
222+
"""
223+
return

pyghmi/ipmi/oem/lenovo/handler.py

+21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616

1717
import base64
18+
import binascii
1819
import traceback
1920
import urllib
2021

@@ -38,6 +39,8 @@
3839

3940
import pyghmi.util.webclient as wc
4041

42+
import socket
43+
4144
inventory.register_inventory_category(cpu)
4245
inventory.register_inventory_category(dimm)
4346
inventory.register_inventory_category(pci)
@@ -521,3 +524,21 @@ def get_graphical_console(self):
521524
return self._get_ts_remote_console(self.ipmicmd.bmc,
522525
self.ipmicmd.ipmi_session.userid,
523526
self.ipmicmd.ipmi_session.password)
527+
528+
def add_extra_net_configuration(self, netdata):
529+
if self.has_tsm:
530+
ipv6_addr = self.ipmicmd.xraw_command(
531+
netfn=0x0c, command=0x02,
532+
data=(0x01, 0xc5, 0x00, 0x00))["data"][1:]
533+
if not ipv6_addr:
534+
return
535+
ipv6_prefix = ord(self.ipmicmd.xraw_command(
536+
netfn=0xc, command=0x02,
537+
data=(0x1, 0xc6, 0, 0))['data'][1])
538+
if hasattr(socket, 'inet_ntop'):
539+
ipv6str = socket.inet_ntop(socket.AF_INET6, ipv6_addr)
540+
else:
541+
# fall back to a dumber, but more universal formatter
542+
ipv6str = binascii.b2a_hex(ipv6_addr)
543+
ipv6str = ':'.join([ipv6str[x:x+4] for x in xrange(0, 32, 4)])
544+
netdata['ipv6_address'] = '{0}/{1}'.format(ipv6str, ipv6_prefix)

0 commit comments

Comments
 (0)