Merge "Add --baremetal-deployment to overcloud deploy cmd"
This commit is contained in:
commit
6c12ce6d7c
|
@ -1472,6 +1472,62 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
@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):
|
||||
mock_write.return_value = (
|
||||
'/tmp/tht/user-environments/baremetal-deployed.yaml',
|
||||
'overcloud/user-environments/baremetal-deployed.yaml'
|
||||
)
|
||||
mock_deploy_roles.return_value = {
|
||||
'parameter_defaults': {'foo': 'bar'}
|
||||
}
|
||||
|
||||
bm_deploy_path = self.tmp_dir.join('bm_deploy.yaml')
|
||||
deploy_data = [
|
||||
{'name': 'Compute', 'count': 10},
|
||||
{'name': 'Controller', 'count': 3},
|
||||
]
|
||||
with open(bm_deploy_path, 'w') as temp_file:
|
||||
yaml.safe_dump(deploy_data, temp_file)
|
||||
|
||||
ssh_key_path = self.tmp_dir.join('id_rsa.pub')
|
||||
with open(ssh_key_path, 'w') as temp_file:
|
||||
temp_file.write('sekrit')
|
||||
|
||||
arglist = [
|
||||
'--baremetal-deployment', bm_deploy_path,
|
||||
'--overcloud-ssh-key', ssh_key_path
|
||||
]
|
||||
verifylist = [
|
||||
('baremetal_deployment', bm_deploy_path),
|
||||
('overcloud_ssh_key', ssh_key_path),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
tht_root = '/tmp/tht'
|
||||
result = self.cmd._provision_baremetal(parsed_args, tht_root)
|
||||
self.assertEqual(
|
||||
['/tmp/tht/user-environments/baremetal-deployed.yaml'],
|
||||
result
|
||||
)
|
||||
mock_deploy_roles.assert_called_once_with(
|
||||
self.app.client_manager,
|
||||
roles=deploy_data,
|
||||
ssh_keys=['sekrit'],
|
||||
ssh_user_name='heat-admin'
|
||||
)
|
||||
mock_write.assert_called_once_with(
|
||||
self.cmd,
|
||||
{'parameter_defaults': {'foo': 'bar'}},
|
||||
'baremetal-deployed.yaml',
|
||||
'/tmp/tht',
|
||||
'overcloud'
|
||||
)
|
||||
|
||||
|
||||
class TestArgumentValidation(fakes.TestDeployOvercloud):
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ from tripleoclient import command
|
|||
from tripleoclient import constants
|
||||
from tripleoclient import exceptions
|
||||
from tripleoclient import utils
|
||||
from tripleoclient.workflows import baremetal
|
||||
from tripleoclient.workflows import deployment
|
||||
from tripleoclient.workflows import parameters as workflow_params
|
||||
from tripleoclient.workflows import plan_management
|
||||
|
@ -394,6 +395,9 @@ class DeployOvercloud(command.Command):
|
|||
env = {}
|
||||
created_env_files = []
|
||||
|
||||
created_env_files.extend(
|
||||
self._provision_baremetal(parsed_args, tht_root))
|
||||
|
||||
if parsed_args.environment_directories:
|
||||
created_env_files.extend(utils.load_environment_directories(
|
||||
parsed_args.environment_directories))
|
||||
|
@ -560,6 +564,12 @@ class DeployOvercloud(command.Command):
|
|||
"Error: The following files were not found: {0}".format(
|
||||
", ".join(nonexisting_envs)))
|
||||
|
||||
if (parsed_args.baremetal_deployment
|
||||
and not parsed_args.deployed_server):
|
||||
raise oscexc.CommandError(
|
||||
"Error: --deployed-server must be used when using "
|
||||
"--baremetal-deployment")
|
||||
|
||||
if parsed_args.deployed_server and (parsed_args.run_validations
|
||||
or not parsed_args.disable_validations):
|
||||
raise oscexc.CommandError(
|
||||
|
@ -607,6 +617,29 @@ class DeployOvercloud(command.Command):
|
|||
|
||||
return default_role_counts
|
||||
|
||||
def _provision_baremetal(self, parsed_args, tht_root):
|
||||
|
||||
if not parsed_args.baremetal_deployment:
|
||||
return []
|
||||
|
||||
with open(parsed_args.baremetal_deployment, 'r') as fp:
|
||||
roles = yaml.safe_load(fp)
|
||||
|
||||
with open(parsed_args.overcloud_ssh_key, 'rt') as fp:
|
||||
ssh_key = fp.read()
|
||||
|
||||
parameter_defaults = baremetal.deploy_roles(
|
||||
self.app.client_manager,
|
||||
roles=roles, ssh_keys=[ssh_key],
|
||||
ssh_user_name=parsed_args.overcloud_ssh_user)
|
||||
|
||||
env_path, swift_path = self._write_user_environment(
|
||||
parameter_defaults,
|
||||
'baremetal-deployed.yaml',
|
||||
tht_root,
|
||||
parsed_args.stack)
|
||||
return [env_path]
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
# add_help doesn't work properly, set it to False:
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -835,6 +868,10 @@ class DeployOvercloud(command.Command):
|
|||
'the deployment actions. This may need to '
|
||||
'be used if deploying on a python2 host '
|
||||
'from a python3 system or vice versa.'))
|
||||
parser.add_argument('-b', '--baremetal-deployment',
|
||||
metavar='<baremetal_deployment.yaml>',
|
||||
help=_('Configuration file describing the '
|
||||
'baremetal deployment'))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
|
Loading…
Reference in New Issue