def decommission_all(): """De-provisions all nodes.""" configure() use_only(*instances_with_platform_and_role(env.platform, env.role)) if len(env.nodes) == 0: info("There are no nodes to decommission.") else: show() if confirm("Are you sure you want to decommission ALL %d nodes?" % len(env.nodes), default=False): decommission_nodes()
def list_nodes(): """List all nodes.""" configure() print("") nodes = classify_nodes() if nodes[INACTIVE]: print("") print(magenta("** INACTIVE nodes **")) if lb_specified(): print(magenta("INACTIVE nodes are nodes not behind the load balancer.")) elif virtual_ip_specified(): print(magenta("INACTIVE nodes are nodes not behind the virtual IP.")) else: print(magenta("INACTIVE nodes are nodes in excess of the target cluster size.")) if len(nodes[ORPHAN]) > 0: print(magenta("To decommission INACTIVE and ORPHAN nodes, use the prune task.")) else: print(magenta("To decommission these nodes, use the prune task.")) show(nodes[INACTIVE]) if nodes[ORPHAN]: print("") print(red("** ORPHAN nodes **")) if lb_specified(): print(red("ORPHAN nodes are nodes not behind the load balancer but ought to be according to target cluster size and node id sequence.")) elif virtual_ip_specified(): print(red("ORPHAN nodes are nodes not behind the virtual IP but ought to be according to target cluster size and node id sequence.")) if nodes[INACTIVE]: print(red("To decommission INACTIVE and ORPHAN nodes, use the prune task.")) else: print(red("To decommission these nodes, use the prune task.")) show(nodes[ORPHAN]) if nodes[EXTRA]: print(cyan("** EXTRA nodes **")) print(cyan("EXTRA nodes are nodes in excess of the target cluster size but live behind the load balancer.")) print(cyan("To decommission these nodes, use the scale_down task.")) show(nodes[EXTRA]) if nodes[ACTIVE]: print("") print(green("** ACTIVE nodes **")) if lb_specified(): print(green("ACTIVE nodes are nodes behind the load balancer and current according to target cluster size and node id sequence.")) elif virtual_ip_specified(): print(green("ACTIVE nodes are nodes behind the virtual IP and current according to the node id sequence.")) show(nodes[ACTIVE]) if nodes[ACTIVE] or nodes[ORPHAN] or nodes[EXTRA] or nodes[INACTIVE]: print("") print("To decommission all nodes, use the teardown task.") print("To connect to a node, use:") print(green("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@<ip address>" % (env.key_filename[0], env.user))) else: print(cyan("There are no nodes in the cluster."))