Fix completion for all nodes

This commit is contained in:
Joshua Boniface 2022-10-27 14:08:53 +00:00
parent 1c3c59b6f0
commit 5db1438328
2 changed files with 16 additions and 5 deletions

View File

@ -84,3 +84,16 @@ def set_boot_state(config, cspec, data, state):
db.update_node_state(config, cspec_cluster, cspec_hostname, state)
node = db.get_node(config, cspec_cluster, name=cspec_hostname)
logger.debug(node)
def set_completed(config, cspec, cluster):
nodes = list()
for bmc_macaddr in cspec["bootstrap"]:
if cspec["bootstrap"][bmc_macaddr]["node"]["cluster"] == cluster:
nodes.append(cspec["bootstrap"][bmc_macaddr])
for node in nodes:
cspec_cluster = node["node"]["cluster"]
cspec_hostname = node["node"]["hostname"]
db.update_node_state(config, cspec_cluster, cspec_hostname, "completed")
node = db.get_node(config, cspec_cluster, name=cspec_hostname)
logger.debug(node)

View File

@ -51,11 +51,11 @@ def dnsmasq_checkin(config, data):
cspec = git.load_cspec_yaml(config)
is_in_bootstrap_map = True if data["macaddr"] in cspec["bootstrap"] else False
try:
if is_in_bootstrap_map
if is_in_bootstrap_map:
cspec_cluster = cspec["bootstrap"][data["macaddr"]]["node"]["cluster"]
is_registered = True if data["macaddr"] in [x.bmc_macaddr for x in db.get_nodes_in_cluster(config, cspec_cluster)] else False
else:
raise Exception()
is_registered = False
except Exception:
is_registered = False
@ -154,9 +154,7 @@ def host_checkin(config, data):
hooks.run_hooks(config, cspec, cluster, ready_nodes)
target_state = "completed"
for node in all_nodes:
host.set_boot_state(config, cspec, data, target_state)
host.set_completed(config, cspec, cluster)
# Hosts will now power down ready for real activation in production
sleep(60)