Add --validate-only to openstack overcloud node import

Previously there was 'openstack baremetal instackenv validate' to
quickly validate an environment file.

Much of which is now done in the validate_nodes mistral workflow.  Add a
mode to cease operations after validating the environment file

Note on the backport:
The old command was removed in Queens, so we need to backport this
new flag to fill in the gap. The workflow was introduced in Pike.

Closes-Bug: #1768604
Change-Id: Ie2bfc79b45f4652285718be34a5e07ce5777c60d
(cherry picked from commit ebc64b681c)
This commit is contained in:
Tony Breeds 2017-12-18 12:22:24 +11:00 committed by Dmitry Tantsur
parent 0b1565d88c
commit c0b7bad64e
2 changed files with 38 additions and 0 deletions

View File

@ -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

View File

@ -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