mirror of
https://opendev.org/x/pyghmi
synced 2026-04-02 16:16:26 +00:00
Detect 'default' nic by matching connection address
This carries forward the configure 'default' nic for systems that nominally have multiple interfaces. Change-Id: I5916efde5aa57d7682fe08eff0fdc8864d79aa52
This commit is contained in:
@@ -254,6 +254,11 @@ class Command(object):
|
||||
self._varfwinventory = None
|
||||
self._oem = None
|
||||
self._gpool = pool
|
||||
for addrinf in socket.getaddrinfo(bmc, 0, 0, socket.SOCK_STREAM):
|
||||
if addrinf[0] == socket.AF_INET:
|
||||
self._bmcv4ip = socket.inet_pton(addrinf[0], addrinf[-1][0])
|
||||
elif addrinf[0] == socket.AF_INET6:
|
||||
self._bmcv6ip = socket.inet_pton(addrinf[0], addrinf[-1][0])
|
||||
self.wc.set_header('Accept', 'application/json')
|
||||
self.wc.set_header('User-Agent', 'pyghmi')
|
||||
self.wc.set_header('Accept-Encoding', 'gzip')
|
||||
@@ -807,6 +812,16 @@ class Command(object):
|
||||
if not nicinfo.get('InterfaceEnabled', True):
|
||||
# skip disabled interfaces
|
||||
continue
|
||||
for addrs in nicinfo.get('IPv4Addresses', []):
|
||||
v4addr = socket.inet_pton(
|
||||
socket.AF_INET, addrs.get('Address', '0.0.0.0'))
|
||||
if self._bmcv4ip == v4addr:
|
||||
return curl
|
||||
for addrs in nicinfo.get('IPv6Addresses', []):
|
||||
v6addr = socket.inet_pton(
|
||||
socket.AF_INET6, addrs.get('Address', '::'))
|
||||
if self._bmcv6ip == v6addr:
|
||||
return curl
|
||||
foundnics += 1
|
||||
lastnicurl = curl
|
||||
if name is None and foundnics != 1:
|
||||
|
||||
Reference in New Issue
Block a user