def run_validations(clients, workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient results = [] with tripleoclients.messaging_websocket() as ws: if 'group_names' in workflow_input: print('Running group validations') execution = base.start_workflow( workflow_client, 'tripleo.validations.v1.run_groups', workflow_input=workflow_input ) else: print('Running single validations') execution = base.start_workflow( workflow_client, 'tripleo.validations.v1.run_validations', workflow_input=workflow_input ) for payload in base.wait_for_messages(workflow_client, ws, execution): if payload.get('message') is None: if payload.get('status') in ['SUCCESS', 'FAILED']: results.append(payload) return results
def clean_nodes(clients, **workflow_input): """Clean Baremetal Nodes Run the tripleo.baremetal.v1.clean_nodes Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.clean_nodes', workflow_input={'node_uuids': workflow_input['node_uuids']}) for payload in base.wait_for_messages(workflow_client, ws, execution): if payload.get('message'): print(payload['message']) if payload['status'] != 'SUCCESS': message = _format_errors(payload) raise exceptions.NodeConfigurationError( 'Error(s) cleaning nodes:\n{}'.format(message)) print('Successfully cleaned nodes')
def config_download(log, clients, stack, templates, ssh_user, ssh_key, ssh_network, output_dir, verbosity=1): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient workflow_input = { 'verbosity': verbosity or 1, 'plan_name': stack.stack_name, 'ssh_network': ssh_network } if output_dir: workflow_input.update(dict(work_dir=output_dir)) with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.deployment.v1.config_download_deploy', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution, 3600): print(payload['message']) if payload['status'] == 'SUCCESS': print("Overcloud configuration completed.") else: raise exceptions.DeploymentError("Overcloud configuration failed.")
def configure_manageable_nodes(clients, **workflow_input): """Configure all manageable Nodes. Run the tripleo.baremetal.v1.configure_manageable_nodes Mistral workflow. """ workflow_client = clients.workflow_engine ooo_client = clients.tripleoclient with ooo_client.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.configure_manageable_nodes', workflow_input=workflow_input ) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] != 'SUCCESS': raise exceptions.NodeConfigurationError( 'Exception configuring nodes: {}'.format(payload['message'])) print(payload['message'])
def introspect(clients, **workflow_input): """Introspect Baremetal Nodes Run the tripleo.baremetal.v1.introspect Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.introspect', workflow_input={'node_uuids': workflow_input['node_uuids'], 'queue_name': queue_name} ) print("Waiting for introspection to finish...") with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': print('Successfully introspected all nodes.') else: raise exceptions.IntrospectionError( "Introspection completed with errors:\n%s" % '\n' .join(msg for msg in payload['message'] if msg)) print("Introspection completed.")
def register_or_update(clients, **workflow_input): """Node Registration or Update Run the tripleo.baremetal.v1.register_or_update Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.register_or_update', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] == 'SUCCESS': registered_nodes = payload['registered_nodes'] for nd in registered_nodes: print('Successfully registered node UUID %s' % nd['uuid']) return registered_nodes else: raise exceptions.RegisterOrUpdateError( 'Exception registering nodes: {}'.format(payload['message']))
def provide(clients, **workflow_input): """Provide Baremetal Nodes Run the tripleo.baremetal.v1.provide Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.provide', workflow_input={'node_uuids': workflow_input['node_uuids'], 'queue_name': queue_name} ) with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': print('Successfully set all nodes to available.') else: try: message = _format_provide_errors(payload) except Exception: message = 'Failed.' raise exceptions.NodeProvideError( 'Failed to set nodes to available state: {}'.format(message))
def provide(clients, **workflow_input): """Provide Baremetal Nodes Run the tripleo.baremetal.v1.provide Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.provide', workflow_input={'node_uuids': workflow_input['node_uuids']}) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] != 'SUCCESS': try: message = _format_errors(payload) except Exception: message = 'Failed.' raise exceptions.NodeProvideError( 'Failed to set nodes to available state: {}'.format(message))
def register_or_update(clients, **workflow_input): """Node Registration or Update Run the tripleo.baremetal.v1.register_or_update Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.register_or_update', workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': registered_nodes = payload['registered_nodes'] for nd in registered_nodes: print('Successfully registered node UUID %s' % nd['uuid']) return registered_nodes else: raise exceptions.RegisterOrUpdateError( 'Exception registering nodes: {}'.format(payload['message']))
def create_raid_configuration(clients, **workflow_input): """Create RAID configuration on nodes. Run the tripleo.baremetal.v1.create_raid_configuration Mistral workflow. """ workflow_client = clients.workflow_engine ooo_client = clients.tripleoclient print('Creating RAID configuration for given nodes, this may take time') with ooo_client.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.create_raid_configuration', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] == 'SUCCESS': print('Success') else: raise RuntimeError('Failed to create RAID: {}'.format( payload['message']))
def validate_nodes(clients, **workflow_input): """Node Registration or Update Run the tripleo.baremetal.v1.validate_nodes Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.baremetal.v1.validate_nodes', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] == 'SUCCESS': print('Successfully validated environment file') return True else: raise exceptions.RegisterOrUpdateError( 'Exception validating environment file: {}'.format( payload['message']))
def set_deployment_status(clients, status='success', **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient if status == 'success': workflow = 'tripleo.deployment.v1.set_deployment_status_success' elif status == 'failed': workflow = 'tripleo.deployment.v1.set_deployment_status_failed' elif status == 'deploying': workflow = 'tripleo.deployment.v1.set_deployment_status_deploying' else: raise Exception("Can't set unknown deployment status: %s" % status) with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, workflow, workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution, _WORKFLOW_TIMEOUT): # Just continue until workflow is done continue if payload['status'] != 'SUCCESS': raise exceptions.WorkflowServiceError( 'Exception setting deployment status: {}'.format( payload.get('message', '')))
def reset_bios_configuration_on_manageable_nodes(clients, **workflow_input): """Reset BIOS settings on manageable nodes. Run the tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes Mistral workflow. """ workflow_client = clients.workflow_engine ooo_client = clients.tripleoclient print('Reset BIOS settings on manageable nodes, this may take time') with ooo_client.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if payload.get('message'): print(payload['message']) if payload['status'] == 'SUCCESS': print('Success') else: raise RuntimeError('Failed to reset BIOS settings: {}'.format( payload['message']))
def deploy(log, clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient wf_name = 'tripleo.deployment.v1.deploy_plan' with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, wf_name, workflow_input=workflow_input) # The deploy workflow ends once the Heat create/update starts. This # means that is shouldn't take very long. Wait for 10 minutes for # messages from the workflow. for payload in base.wait_for_messages(workflow_client, ws, execution, 600): status = payload.get('status', 'RUNNING') message = payload.get('message') if message and status == "RUNNING": print(message) if payload['status'] != "SUCCESS": log.info(pprint.pformat(payload)) print(payload['message']) raise ValueError("Unexpected status %s for %s" % (payload['status'], wf_name))
def introspect(clients, **workflow_input): """Introspect Baremetal Nodes Run the tripleo.baremetal.v1.introspect Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow(workflow_client, 'tripleo.baremetal.v1.introspect', workflow_input={ 'node_uuids': workflow_input['node_uuids'], 'queue_name': queue_name }) print("Waiting for introspection to finish...") with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': print('Successfully introspected all nodes.') else: raise exceptions.IntrospectionError( "Introspection completed with errors:\n%s" % '\n'.join(msg for msg in payload['message'] if msg)) print("Introspection completed.")
def provide_manageable_nodes(clients, **workflow_input): """Provide all manageable Nodes Run the tripleo.baremetal.v1.provide_manageable_nodes Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.provide_manageable_nodes', workflow_input={ "queue_name": queue_name, }) with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] != 'SUCCESS': raise exceptions.NodeProvideError( 'Exception providing nodes:{}'.format(payload['message'])) print(payload['message'])
def provide(clients, **workflow_input): """Provide Baremetal Nodes Run the tripleo.baremetal.v1.provide Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow(workflow_client, 'tripleo.baremetal.v1.provide', workflow_input={ 'node_uuids': workflow_input['node_uuids'], 'queue_name': queue_name }) with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': print('Successfully set all nodes to available.') else: try: message = _format_provide_errors(payload) except Exception: message = 'Failed.' raise exceptions.NodeProvideError( 'Failed to set nodes to available state: {}'.format(message))
def introspect(clients, **workflow_input): """Introspect Baremetal Nodes Run the tripleo.baremetal.v1.introspect Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient print("Waiting for introspection to finish...") with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.baremetal.v1.introspect', workflow_input={ 'node_uuids': workflow_input['node_uuids'], 'run_validations': workflow_input['run_validations'] }) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: print(payload['message']) if payload['status'] != 'SUCCESS': raise exceptions.IntrospectionError( "Introspection completed with errors:\n%s" % '\n'.join(msg for msg in payload['message'] if msg))
def check_predeployment_validations(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient execution = base.start_workflow( workflow_client, 'tripleo.validations.v1.check_pre_deployment_validations', workflow_input=workflow_input) errors = [] warnings = [] with tripleoclients.messaging_websocket() as ws: for payload in base.wait_for_messages(workflow_client, ws, execution): if payload.get('message'): print(payload['message']) if 'errors' in payload: errors += payload['errors'] if 'warnings' in payload: warnings += payload['warnings'] if errors: print('ERRORS') print(errors) if warnings: print('WARNINGS') print(warnings) return len(errors), len(warnings)
def update(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient plan_name = workflow_input['container'] with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.package_update.v1.package_update_plan', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): assert payload['status'] == "SUCCESS", pprint.pformat(payload) orchestration_client = clients.orchestration events = event_utils.get_events(orchestration_client, stack_id=plan_name, event_args={ 'sort_dir': 'desc', 'limit': 1 }) marker = events[0].id if events else None time.sleep(10) create_result = utils.wait_for_stack_ready(orchestration_client, plan_name, marker, 'UPDATE', 1) if not create_result: shell.OpenStackShell().run(["stack", "failures", "list", plan_name]) raise exceptions.DeploymentError("Heat Stack update failed.")
def delete_container(clients, container, timeout=None, concurrency=None): """Deletes container from swift :param clients: openstack clients :param container: name of the container where the logs were stored :param timeout: timeout for the delete operations :param concurrency: max number of object deletion tasks to run at one time """ workflow_input = { "container": container, } if timeout is not None: workflow_input['timeout'] = timeout if concurrency is not None: workflow_input['concurrency'] = concurrency workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient execution = base.start_workflow(workflow_client, 'tripleo.support.v1.delete_container', workflow_input=workflow_input) websocket = tripleoclients.messaging_websocket() messages = base.wait_for_messages(workflow_client, websocket, execution, timeout) for message in messages: if message['status'] != 'SUCCESS': raise ContainerDeleteFailed(message['message']) if message['message']: print('{}'.format(message['message']))
def check_deprecated_parameters(clients, container): """Checks for deprecated parameters in plan and adds warning if present""" workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient workflow_input = {'container': container} with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.plan_management.v1.get_deprecated_parameters', workflow_input=workflow_input) messages = base.wait_for_messages(workflow_client, ws, execution, 120) deprecated_params = [] unused_params = [] for message in messages: if message['status'] == 'SUCCESS': for param in message.get('deprecated', []): if param.get('user_defined'): deprecated_params.append(param['parameter']) unused_params = message.get('unused', []) if deprecated_params: print('WARNING: Following parameters are deprecated and still ' 'defined. Deprecated parameters will be removed soon!') print('\n'.join( [' {}'.format(param) for param in deprecated_params])) if unused_params: print('WARNING: Following parameters are defined but not used in ' 'plan. Could be possible that parameter is valid but ' 'currently not used.') print('\n'.join([' {}'.format(param) for param in unused_params]))
def check_deprecated_parameters(clients, container): """Checks for deprecated parameters in plan and adds warning if present""" workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient workflow_input = {'container': container} with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.plan_management.v1.get_deprecated_parameters', workflow_input=workflow_input) messages = base.wait_for_messages(workflow_client, ws, execution, 120) deprecated_params = [] unused_params = [] invalid_role_specific_params = [] for message in messages: if message['status'] == 'SUCCESS': for param in message.get('deprecated', []): if param.get('user_defined'): deprecated_params.append(param['parameter']) unused_params = message.get('unused', []) invalid_role_specific_params = message.get( 'invalid_role_specific', []) if deprecated_params: deprecated_join = ', '.join( ['{param}'.format(param=param) for param in deprecated_params]) LOG.warning( 'WARNING: Following parameter(s) are deprecated and still ' 'defined. Deprecated parameters will be removed soon!' ' {deprecated_join}'.format(deprecated_join=deprecated_join)) # exclude our known params that may not be used ignore_re = re.compile('|'.join(UNUSED_PARAMETER_EXCLUDES_RE)) unused_params = [p for p in unused_params if not ignore_re.search(p)] if unused_params: unused_join = ', '.join( ['{param}'.format(param=param) for param in unused_params]) LOG.warning( 'WARNING: Following parameter(s) are defined but not ' 'currently used in the deployment plan. These parameters ' 'may be valid but not in use due to the service or ' 'deployment configuration.' ' {unused_join}'.format(unused_join=unused_join)) if invalid_role_specific_params: invalid_join = ', '.join([ '{param}'.format(param=param) for param in invalid_role_specific_params ]) LOG.warning('WARNING: Following parameter(s) are not supported as ' 'role-specific inputs. {invalid_join}'.format( invalid_join=invalid_join))
def _create_update_deployment_plan(clients, workflow, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow(workflow_client, workflow, workflow_input=workflow_input) with tripleoclients.messaging_websocket(queue_name) as ws: return ws.wait_for_message(execution.id)
def _create_update_deployment_plan(clients, workflow, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, workflow, workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: return base.wait_for_message(workflow_client, ws, execution, _WORKFLOW_TIMEOUT)
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 deploy(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow(workflow_client, 'tripleo.deployment.v1.deploy_plan', workflow_input=workflow_input) with tripleoclients.messaging_websocket(queue_name) as ws: message = ws.wait_for_message(execution.id) assert message['status'] == "SUCCESS", pprint.pformat(message)
def config_download(log, clients, stack, templates, ssh_user, ssh_key, ssh_network, output_dir, override_ansible_cfg, timeout, verbosity=1, deployment_options={}, in_flight_validations=False): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient if in_flight_validations: skip_tags = '' else: skip_tags = 'opendev-validation' workflow_input = { 'verbosity': verbosity, 'plan_name': stack.stack_name, 'ssh_network': ssh_network, 'config_download_timeout': timeout, 'deployment_options': deployment_options, 'skip_tags': skip_tags } if output_dir: workflow_input.update(dict(work_dir=output_dir)) if override_ansible_cfg: with open(override_ansible_cfg) as cfg: override_ansible_cfg_contents = cfg.read() workflow_input.update( dict(override_ansible_cfg=override_ansible_cfg_contents)) with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.deployment.v1.config_download_deploy', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): print(payload['message']) if payload['status'] == 'SUCCESS': print("Overcloud configuration completed.") else: raise exceptions.DeploymentError("Overcloud configuration failed.")
def backup(clients, workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.undercloud_backup.v1.backup', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: assert payload['status'] == "SUCCESS", pprint.pformat(payload) print('Undercloud Backup succeed')
def get_horizon_url(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.deployment.v1.get_horizon_url', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution, 360): assert payload['status'] == "SUCCESS" return payload['horizon_url']
def _create_update_deployment_plan(clients, workflow, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, workflow, workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution, _WORKFLOW_TIMEOUT): if 'message' in payload: print(payload['message']) return payload
def delete_node(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.scale.v1.delete_node', workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: rtn_message = ws.wait_for_message(execution.id) if rtn_message['status'] != "SUCCESS": raise InvalidConfiguration(rtn_message['message'])
def deploy(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.deployment.v1.deploy_plan', workflow_input=workflow_input) # The deploy workflow ends once the Heat create/update starts. This # means that is shouldn't take very long. Wait for six minutes for # messages from the workflow. for payload in base.wait_for_messages(workflow_client, ws, execution, 360): assert payload['status'] == "SUCCESS", pprint.pformat(payload)
def get_config(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow(workflow_client, 'tripleo.package_update.v1.get_config', workflow_input=workflow_input) for payload in base.wait_for_messages(workflow_client, ws, execution): assert payload['status'] == "SUCCESS", pprint.pformat(payload) if payload['status'] == 'SUCCESS': print('Success') else: raise RuntimeError('Minor update failed with: {}'.format(payload))
def list_validations(clients, workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient with tripleoclients.messaging_websocket() as ws: execution = base.start_workflow( workflow_client, 'tripleo.validations.v1.list', workflow_input=workflow_input ) for payload in base.wait_for_messages(workflow_client, ws, execution): if 'message' in payload: assert payload['status'] == "SUCCESS", pprint.pformat(payload) return payload['validations']
def introspect_manageable_nodes(clients, **workflow_input): """Introspect all manageable nodes Run the tripleo.baremetal.v1.introspect_manageable_nodes Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.introspect_manageable_nodes', workflow_input={"queue_name": queue_name, } ) print("Waiting for introspection to finish...") errors = [] successful_node_uuids = set() with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] == 'SUCCESS': introspected_nodes = payload['introspected_nodes'] or {} for node_uuid, status in introspected_nodes.items(): if status['error'] is None: print(("Introspection for UUID {0} finished " "successfully.").format(node_uuid)) successful_node_uuids.add(node_uuid) else: print(("Introspection for UUID {0} finished with error" ": {1}").format(node_uuid, status['error'])) errors.append("%s: %s" % (node_uuid, status['error'])) if not introspected_nodes: print("No nodes in manageable state found for introspection.") else: raise exceptions.IntrospectionError( 'Exception introspecting nodes: {}'.format(payload['message'])) if errors: raise exceptions.IntrospectionError( "Introspection completed with errors:\n%s" % '\n' .join(errors)) print("Introspection completed.")
def deploy(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.deployment.v1.deploy_plan', workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: # The deploy workflow ends once the Heat create/update starts. This # means that is shouldn't take very long. Wait for six minutes for # messages from the workflow. message = ws.wait_for_message(execution.id, 360) # 6 * 60 seconds assert message['status'] == "SUCCESS", pprint.pformat(message)
def create_default_plan(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.plan_management.v1.create_default_deployment_plan', workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: payload = base.wait_for_message(workflow_client, ws, execution, _WORKFLOW_TIMEOUT) if payload['status'] == 'SUCCESS': print("Default plan created") else: raise exceptions.WorkflowServiceError( 'Exception creating plan: {}'.format(payload['message']))
def configure(clients, **workflow_input): """Configure Node boot options. Run the tripleo.baremetal.v1.configure Mistral workflow. """ workflow_client = clients.workflow_engine ooo_client = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.configure', workflow_input=workflow_input ) with ooo_client.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] != 'SUCCESS': raise exceptions.NodeConfigurationError( 'Failed to configure nodes: {}'.format(payload['message']))
def get_overcloud_passwords(clients, **workflow_input): """Retrieves overcloud passwords from a plan via a workflow :param clients: :param workflow_input: :return: """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.plan_management.v1.get_passwords', workflow_input=workflow_input ) with tripleoclients.messaging_websocket(queue_name) as ws: # Getting the passwords is a quick operation, but to allow space for # delays or heavy loads, timeout after 60 seconds. payload = base.wait_for_message(workflow_client, ws, execution, 60) assert payload['status'] == "SUCCESS" return payload['message']
def provide_manageable_nodes(clients, **workflow_input): """Provide all manageable Nodes Run the tripleo.baremetal.v1.provide_manageable_nodes Mistral workflow. """ workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient queue_name = workflow_input['queue_name'] execution = base.start_workflow( workflow_client, 'tripleo.baremetal.v1.provide_manageable_nodes', workflow_input={"queue_name": queue_name, } ) with tripleoclients.messaging_websocket(queue_name) as ws: payload = ws.wait_for_message(execution.id) if payload['status'] != 'SUCCESS': raise exceptions.NodeProvideError( 'Exception providing nodes:{}'.format(payload['message'])) print(payload['message'])