Complete overcloud deploy --baremetal-deployment
The overcloud deploy --baremetal-deployment argument is an alternative
to calling the provision and unprovision commands separately, giving
users the option of only needing to call overcloud deploy to also
manage baremetal.
This change does the following:
- adds the missing plan argument to deploy_roles to support
multi-overcloud
- calls undeploy_roles after the heat stack operation, to unprovision
any nodes that are flagged as provisioned:false
This is a medium-risk backport because overcloud deploy is frequently
run, but the code-path is only used when the --baremetal-deployment
argument is passed (which is not documented in stable/train)
Blueprint: nova-less-deploy
Change-Id: Ia4d064d7b039ef3afcee38de8ad1aa47f035a263
(cherry picked from commit 69aad030d3
)
This commit is contained in:
parent
f15890bdff
commit
6acea63122
|
@ -1504,11 +1504,14 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
@mock.patch('tripleoclient.workflows.baremetal.undeploy_roles',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.baremetal.deploy_roles',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_write_user_environment', autospec=True)
|
||||
def test_provision_baremetal(self, mock_write, mock_deploy_roles):
|
||||
def test_provision_baremetal(self, mock_write, mock_deploy_roles,
|
||||
mock_undeploy_roles):
|
||||
mock_write.return_value = (
|
||||
'/tmp/tht/user-environments/baremetal-deployed.yaml',
|
||||
'overcloud/user-environments/baremetal-deployed.yaml'
|
||||
|
@ -1542,16 +1545,23 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
tht_root = '/tmp/tht'
|
||||
result = self.cmd._provision_baremetal(parsed_args, tht_root)
|
||||
self.cmd._unprovision_baremetal(parsed_args)
|
||||
self.assertEqual(
|
||||
['/tmp/tht/user-environments/baremetal-deployed.yaml'],
|
||||
result
|
||||
)
|
||||
mock_deploy_roles.assert_called_once_with(
|
||||
self.app.client_manager,
|
||||
plan='overcloud',
|
||||
roles=deploy_data,
|
||||
ssh_keys=['sekrit'],
|
||||
ssh_user_name='heat-admin'
|
||||
)
|
||||
mock_undeploy_roles.assert_called_once_with(
|
||||
self.app.client_manager,
|
||||
plan='overcloud',
|
||||
roles=deploy_data
|
||||
)
|
||||
mock_write.assert_called_once_with(
|
||||
self.cmd,
|
||||
{'parameter_defaults': {'foo': 'bar'}},
|
||||
|
|
|
@ -471,6 +471,8 @@ class DeployOvercloud(command.Command):
|
|||
parsed_args.plan_environment_file,
|
||||
deployment_options=deployment_options)
|
||||
|
||||
self._unprovision_baremetal(parsed_args)
|
||||
|
||||
def _try_overcloud_deploy_with_compat_yaml(self, tht_root, stack,
|
||||
stack_name, parameters,
|
||||
env_files, timeout,
|
||||
|
@ -625,6 +627,7 @@ class DeployOvercloud(command.Command):
|
|||
|
||||
parameter_defaults = baremetal.deploy_roles(
|
||||
self.app.client_manager,
|
||||
plan=parsed_args.stack,
|
||||
roles=roles, ssh_keys=[ssh_key],
|
||||
ssh_user_name=parsed_args.overcloud_ssh_user)
|
||||
|
||||
|
@ -635,6 +638,20 @@ class DeployOvercloud(command.Command):
|
|||
parsed_args.stack)
|
||||
return [env_path]
|
||||
|
||||
def _unprovision_baremetal(self, parsed_args):
|
||||
|
||||
if not parsed_args.baremetal_deployment:
|
||||
return
|
||||
|
||||
with open(parsed_args.baremetal_deployment, 'r') as fp:
|
||||
roles = yaml.safe_load(fp)
|
||||
|
||||
baremetal.undeploy_roles(
|
||||
self.app.client_manager,
|
||||
plan=parsed_args.stack,
|
||||
roles=roles
|
||||
)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
# add_help doesn't work properly, set it to False:
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
Loading…
Reference in New Issue