diff --git a/tripleoclient/v1/overcloud_node.py b/tripleoclient/v1/overcloud_node.py index 0ff413c8a..f6df211a1 100644 --- a/tripleoclient/v1/overcloud_node.py +++ b/tripleoclient/v1/overcloud_node.py @@ -194,6 +194,10 @@ class ImportNode(command.Command): help=_('Run the pre-deployment validations. These ' 'external validations are from the TripleO ' 'Validations project.')) + parser.add_argument('--validate-only', action='store_true', + default=False, + help=_('Validate the env_file and then exit ' + 'without actually importing the nodes.')) parser.add_argument('--provide', action='store_true', help=_('Provide (make available) the nodes')) @@ -213,6 +217,10 @@ class ImportNode(command.Command): nodes_config = oooutils.parse_env_file(parsed_args.env_file) + if parsed_args.validate_only: + return baremetal.validate_nodes(self.app.client_manager, + nodes_json=nodes_config) + if parsed_args.no_deploy_image: deploy_kernel = None deploy_ramdisk = None diff --git a/tripleoclient/workflows/baremetal.py b/tripleoclient/workflows/baremetal.py index e0a24c0fc..18f3aa732 100644 --- a/tripleoclient/workflows/baremetal.py +++ b/tripleoclient/workflows/baremetal.py @@ -18,6 +18,36 @@ from tripleoclient import exceptions from tripleoclient.workflows import base +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 register_or_update(clients, **workflow_input): """Node Registration or Update