From fdc4e959f741ac4761ccaeec830b4ef02bcc84cc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 5 Oct 2017 10:16:49 -0400 Subject: [PATCH] Populate nodename on pxe entries when possible If a PXE is matched by UUID, populate the nodename just like the serial number and such. --- confluent_server/confluent/discovery/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index fd69b28a..996818ff 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -150,6 +150,7 @@ pending_nodes = {} def enrich_pxe_info(info): sn = None mn = None + nodename = info.get('nodename', None) uuid = info.get('uuid', '') if not uuid_is_valid(uuid): return info @@ -158,6 +159,9 @@ def enrich_pxe_info(info): info['serialnumber'] = known_uuids[uuid][mac]['serialnumber'] if not mn and 'modelnumber' in known_uuids[uuid][mac]: info['modelnumber'] = known_uuids[uuid][mac]['modelnumber'] + if nodename is None and 'nodename' in known_uuids[uuid][mac]: + info['nodename'] = known_uuids[uuid][mac]['nodename'] + def uuid_is_valid(uuid): @@ -170,10 +174,10 @@ def uuid_is_valid(uuid): def send_discovery_datum(info): addresses = info.get('addresses', []) - yield msg.KeyValueData({'nodename': info.get('nodename', '')}) - yield msg.KeyValueData({'ipaddrs': [x[0] for x in 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]}) sn = info.get('serialnumber', '') mn = info.get('modelnumber', '') uuid = info.get('uuid', '')