diff --git a/bootstrap-daemon/pvcbootstrapd/lib/host.py b/bootstrap-daemon/pvcbootstrapd/lib/host.py index 363e265..4c7d924 100755 --- a/bootstrap-daemon/pvcbootstrapd/lib/host.py +++ b/bootstrap-daemon/pvcbootstrapd/lib/host.py @@ -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) diff --git a/bootstrap-daemon/pvcbootstrapd/lib/lib.py b/bootstrap-daemon/pvcbootstrapd/lib/lib.py index b023a31..12e41c0 100755 --- a/bootstrap-daemon/pvcbootstrapd/lib/lib.py +++ b/bootstrap-daemon/pvcbootstrapd/lib/lib.py @@ -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)