2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-13 19:27:51 +00:00

Add a more specific error if we have a guess about nodename

If a manual add procedure has not
specified a mac or uuid, but
the discovery framework has a guess about it,
have that guess appear
in events with suggestion on
how to proceed.
This commit is contained in:
Jarrod Johnson 2021-08-12 13:07:57 -04:00
parent e9bc7ebe8d
commit 0f543c80e9
2 changed files with 35 additions and 8 deletions

View File

@ -912,6 +912,13 @@ def get_nodename_from_chained_smms(cfg, handler, info):
nodename = newnodename
return nodename
def get_node_guess_by_uuid(uuid):
for mac in known_uuids.get(uuid, {}):
nodename = known_uuids[uuid][mac].get('nodename', None)
if nodename:
return nodename
return None
def get_node_by_uuid_or_mac(uuidormac):
node = pxe.macmap.get(uuidormac, None)
if node is not None:
@ -1326,7 +1333,7 @@ def stop_autosense():
def start_autosense():
autosensors.add(eventlet.spawn(slp.snoop, safe_detected, slp))
autosensors.add(eventlet.spawn(pxe.snoop, safe_detected, pxe))
autosensors.add(eventlet.spawn(pxe.snoop, safe_detected, pxe, get_node_guess_by_uuid))
nodes_by_fprint = {}

View File

@ -301,7 +301,7 @@ def start_proxydhcp():
eventlet.spawn_n(proxydhcp)
def snoop(handler, protocol=None):
def snoop(handler, protocol=None, nodeguess=None):
#TODO(jjohnson2): ipv6 socket and multicast for DHCPv6, should that be
#prominent
#TODO(jjohnson2): enable unicast replies. This would suggest either
@ -399,7 +399,7 @@ def snoop(handler, protocol=None):
and time.time() > ignoredisco.get(netaddr, 0) + 60):
ignoredisco[netaddr] = time.time()
handler(info)
consider_discover(info, rqinfo, net4, cfg, rqv)
consider_discover(info, rqinfo, net4, cfg, rqv, nodeguess)
except Exception as e:
tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event,
event=log.Events.stacktrace)
@ -638,7 +638,7 @@ def ack_request(pkt, rq, info):
repview[26:28] = struct.pack('!H', datasum)
send_raw_packet(repview, len(rply), rq, info)
def consider_discover(info, packet, sock, cfg, reqview):
def consider_discover(info, packet, sock, cfg, reqview, nodeguess):
if info.get('hwaddr', None) in macmap and info.get('uuid', None):
check_reply(macmap[info['hwaddr']], info, packet, sock, cfg, reqview)
elif info.get('uuid', None) in uuidmap:
@ -648,10 +648,30 @@ def consider_discover(info, packet, sock, cfg, reqview):
elif info.get('uuid', None) and info.get('hwaddr', None):
if time.time() > ignoremacs.get(info['hwaddr'], 0) + 90:
ignoremacs[info['hwaddr']] = time.time()
log.log(
{'info': 'No node matches boot attempt from uuid {0} or hardware address {1}'.format(
info['uuid'], info['hwaddr']
)})
maybenode = None
if nodeguess:
maybenode = nodeguess(info['uuid'])
if maybenode:
# originally was going to just offer up the node (the likely
# scenario is that it was manually added, autodiscovery picked
# up the TLS match, and correlated)
# However, since this is technically unverified data, we shouldn't
# act upon it until confirmed by process or user
# So instead, offer a hint about what is probably the case, but
# hasn't yet been approved by anything
log.log(
{'info': 'Boot attempt from uuid {0} or hardware '
'address {1}, which is not confirmed to be a '
'node, but seems to be {2}. To confirm node '
'identity, \'nodediscover reassign -n {2}\' or '
'\'nodeattrib {2} id.uuid={0}\''.format(
info['uuid'], info['hwaddr'], maybenode
)})
else:
log.log(
{'info': 'No node matches boot attempt from uuid {0} or hardware address {1}'.format(
info['uuid'], info['hwaddr']
)})
if __name__ == '__main__':