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

Check for some issues in a manual assign request

One is to provide clear feedback when a nodename is requested
that was not previously defined, to make it more clear that
it is a requirement and/or guard against going too far while
the config function will be missing data it needs to complete
onboarding.

Another is to break if the request is trying to assign a node
to a different definition when it already exists under a different
name.
This commit is contained in:
Jarrod Johnson 2020-10-30 08:18:27 -04:00
parent 3903cda789
commit 40c74699f0

View File

@ -1040,6 +1040,20 @@ def eval_node(cfg, handler, info, nodename, manual=False):
def discover_node(cfg, handler, info, nodename, manual):
if manual:
if not cfg.is_node(nodename):
raise exc.InvalidArgumentException(
'{0} is not a defined node, must be defined before an '
'endpoint may be assigned to it'.format(nodename))
if handler.https_supported:
currcert = handler.https_cert
if currcert:
currprint = util.get_fingerprint(currcert, 'sha256')
prevnode = nodes_by_fprint.get(currprint, None)
if prevnode and prevnode != nodename:
raise exc.InvalidArgumentException(
'Attempt to assign {0} conflicts with existing node {1} '
'based on TLS certificate.'.format(nodename, prevnode))
known_nodes[nodename][info['hwaddr']] = info
if info['hwaddr'] in unknown_info:
del unknown_info[info['hwaddr']]