def scale_down(): """Removes excess nodes from the load balancer (thus extra nodes are made into inactive nodes).""" use_only(*classify_nodes()[EXTRA]) if len(env.nodes) == 0: info("There are no extra nodes to scale down.") else: lb_remove_nodes()
def decommission_unused(): """De-provisions inactive and orphan nodes.""" configure() nodes = classify_nodes() use_only(*nodes[INACTIVE] + nodes[ORPHAN]) if len(env.nodes) == 0: info("There are no inactive or orphan nodes to decommission.") else: decommission_nodes()
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 provision(): """Provisions env.num_nodes new nodes.""" configure() use_only() env.new_nodes = provision_nodes(env.num_nodes, classify_nodes()[MAX_ID] + 1)