2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 02:52:07 +00:00

Python 3.7 fix for ipv6 lla handling

Python 3.7 changes behavior of recfrom (because.. why not apparently...)
Use getnameinfo to normalize the printable version.
This commit is contained in:
Jarrod Johnson 2020-09-02 12:12:10 -04:00
parent 5e01d9c97b
commit 6f55a4ffe0
2 changed files with 8 additions and 2 deletions

View File

@ -81,6 +81,7 @@ import confluent.noderange as noderange
import confluent.util as util
import eventlet
import traceback
import socket as nsocket
webclient = eventlet.import_patched('pyghmi.util.webclient')
@ -206,13 +207,16 @@ def uuid_is_valid(uuid):
'00112233-4455-6677-8899-aabbccddeeff',
'20202020-2020-2020-2020-202020202020')
def _printable_ip(sa):
return nsocket.getnameinfo(
sa, nsocket.NI_NUMERICHOST|nsocket.NI_NUMERICSERV)[0]
def send_discovery_datum(info):
addresses = info.get('addresses', [])
if info['handler'] == pxeh:
enrich_pxe_info(info)
yield msg.KeyValueData({'nodename': info.get('nodename', '')})
yield msg.KeyValueData({'ipaddrs': [x[0] for x in addresses]})
yield msg.KeyValueData({'ipaddrs': [_printable_ip(x) for x in addresses]})
sn = info.get('serialnumber', '')
mn = info.get('modelnumber', '')
uuid = info.get('uuid', '')

View File

@ -14,6 +14,7 @@
import errno
import eventlet
import socket
webclient = eventlet.import_patched('pyghmi.util.webclient')
class NodeHandler(object):
@ -38,7 +39,8 @@ class NodeHandler(object):
else:
if info.get('addresses', False):
targsa = info['addresses'][0]
self.ipaddr = targsa[0]
self.ipaddr = socket.getnameinfo(
targsa, socket.NI_NUMERICHOST|socket.NI_NUMERICSERV)[0]
@classmethod
def adequate(cls, info):