def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager if not parsed_args.yes: confirm = oooutils.prompt_user_for_confirmation(message=_( "Are you sure you want to delete these overcloud " "nodes [y/N]? "), logger=self.log) if not confirm: raise oscexc.CommandError("Action not confirmed, exiting.") orchestration_client = clients.orchestration stack = oooutils.get_stack(orchestration_client, parsed_args.stack) if not stack: raise InvalidConfiguration("stack {} not found".format( parsed_args.stack)) nodes = '\n'.join('- %s' % node for node in parsed_args.nodes) print( "Deleting the following nodes from stack {stack}:\n{nodes}".format( stack=stack.stack_name, nodes=nodes)) scale.scale_down(clients, stack.stack_name, parsed_args.nodes, parsed_args.timeout)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager if parsed_args.baremetal_deployment: with open(parsed_args.baremetal_deployment, 'r') as fp: roles = yaml.safe_load(fp) nodes_text, nodes = self._nodes_to_delete(parsed_args, roles) if nodes_text: print(nodes_text) else: return else: nodes = parsed_args.nodes nodes_text = '\n'.join('- %s' % node for node in nodes) if not parsed_args.yes: confirm = oooutils.prompt_user_for_confirmation(message=_( "Are you sure you want to delete these overcloud " "nodes [y/N]? "), logger=self.log) if not confirm: raise oscexc.CommandError("Action not confirmed, exiting.") orchestration_client = clients.orchestration stack = oooutils.get_stack(orchestration_client, parsed_args.stack) if not stack: raise InvalidConfiguration("stack {} not found".format( parsed_args.stack)) print( "Deleting the following nodes from stack {stack}:\n{nodes}".format( stack=stack.stack_name, nodes=nodes_text)) scale.scale_down( log=self.log, clients=clients, stack=stack, nodes=nodes, connection_timeout=parsed_args.overcloud_ssh_port_timeout, timeout=parsed_args.timeout, verbosity=oooutils.playbook_verbosity(self=self)) if parsed_args.baremetal_deployment: with oooutils.TempDirs() as tmp: oooutils.run_ansible_playbook( playbook='cli-overcloud-node-unprovision.yaml', inventory='localhost,', workdir=tmp, playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS, verbosity=oooutils.playbook_verbosity(self=self), extra_vars={ "stack_name": parsed_args.stack, "baremetal_deployment": roles, "prompt": False, })
def delete_node(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.scale.v1.delete_node', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if payload['status'] != "SUCCESS": raise InvalidConfiguration(payload['message'])
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager orchestration_client = clients.orchestration stack = oooutils.get_stack(orchestration_client, parsed_args.stack) if not stack: raise InvalidConfiguration("stack {} not found".format( parsed_args.stack)) nodes = '\n'.join('- %s' % node for node in parsed_args.nodes) print( "Deleting the following nodes from stack {stack}:\n{nodes}".format( stack=stack.stack_name, nodes=nodes)) scale.scale_down(clients, stack.stack_name, parsed_args.nodes, parsed_args.timeout)
def delete_stack(clients, stack): """Deletes the stack named in the workflow_input. :param workflow_client: Workflow client :param stack: Name or ID of stack to delete """ workflow_client = clients.workflow_engine tripleoclient = clients.tripleoclient workflow_input = {'stack': stack} with tripleoclient.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.stack.v1.delete_stack', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if payload['status'] != "SUCCESS": raise InvalidConfiguration(payload['message'])
def plan_undeploy(clients, plan): """Undeploy the plan and deletes the stack named in the workflow_input. :param workflow_client: Workflow client :param plan: Name or ID of plan to delete """ workflow_client = clients.workflow_engine tripleoclient = clients.tripleoclient workflow_input = {'container': plan} with tripleoclient.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.deployment.v1.undeploy_plan', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): status = payload['status'] if status == 'RUNNING': continue if status != 'SUCCESS': raise InvalidConfiguration(payload['message'])