Integrate Tuskar into openstack overcloud deploy
Change-Id: Ic2a5b959e37bacbd614cbed9712b64b95aaeafb2
This commit is contained in:

committed by
Lennart Regebro

parent
d1f3cf01aa
commit
4714df20cc
@@ -30,6 +30,7 @@ class FakeClientWrapper(object):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = mock.Mock()
|
||||
self._baremetal = mock.Mock()
|
||||
self._management = mock.Mock()
|
||||
|
||||
def orchestration(self):
|
||||
return self._orchestration
|
||||
@@ -37,6 +38,9 @@ class FakeClientWrapper(object):
|
||||
def baremetal(self):
|
||||
return self._baremetal
|
||||
|
||||
def management(self):
|
||||
return self._management
|
||||
|
||||
|
||||
class TestDeployOvercloud(utils.TestCommand):
|
||||
|
||||
|
@@ -91,3 +91,45 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.assertEqual(kwargs['template'], 'template')
|
||||
self.assertEqual(kwargs['environment'], 'env')
|
||||
self.assertEqual(kwargs['stack_name'], 'overcloud')
|
||||
|
||||
@mock.patch('heatclient.common.template_utils.'
|
||||
'process_multiple_environments_and_files')
|
||||
@mock.patch('heatclient.common.template_utils.get_template_contents')
|
||||
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_get_stack')
|
||||
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_pre_heat_deploy')
|
||||
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_post_heat_deploy')
|
||||
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_heat_deploy')
|
||||
def test_tuskar_deploy(self, mock_heat_deploy, mock_post_deploy,
|
||||
most_pre_deploy, mock_get_stack,
|
||||
mock_get_templte_contents,
|
||||
mock_process_multiple_env):
|
||||
|
||||
arglist = ['--plan-uuid', 'UUID', '--output-dir', 'fake']
|
||||
verifylist = [
|
||||
('use_tht', False),
|
||||
('plan_uuid', 'UUID'),
|
||||
('output_dir', 'fake'),
|
||||
]
|
||||
|
||||
clients = self.app.client_manager
|
||||
management = clients.rdomanager_oscplugin.management()
|
||||
|
||||
management.plans.templates.return_value = {}
|
||||
|
||||
mock_get_templte_contents.return_value = ({}, "template")
|
||||
mock_process_multiple_env.return_value = ({}, "envs")
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_heat_deploy.assert_called_with(
|
||||
mock_get_stack(),
|
||||
'fake/plan.yaml',
|
||||
None,
|
||||
['fake/environment.yaml']
|
||||
)
|
||||
|
@@ -18,6 +18,7 @@ import logging
|
||||
import os
|
||||
import six
|
||||
import sys
|
||||
import tempfile
|
||||
import uuid
|
||||
|
||||
from cliff import command
|
||||
@@ -232,7 +233,47 @@ class DeployOvercloud(command.Command):
|
||||
[RESOURCE_REGISTRY_PATH, env_path])
|
||||
|
||||
def _deploy_tuskar(self, stack, parsed_args):
|
||||
pass
|
||||
|
||||
clients = self.app.client_manager
|
||||
management = clients.rdomanager_oscplugin.management()
|
||||
|
||||
# TODO(dmatthews): The Tuskar client has very similar code to this. It
|
||||
# should be refactored upstream so we can use it.
|
||||
|
||||
if parsed_args.output_dir:
|
||||
output_dir = parsed_args.output_dir
|
||||
else:
|
||||
output_dir = tempfile.mkdtemp()
|
||||
|
||||
if not os.path.isdir(output_dir):
|
||||
os.mkdir(output_dir)
|
||||
|
||||
# retrieve templates
|
||||
templates = management.plans.templates(parsed_args.plan_uuid)
|
||||
|
||||
# write file for each key-value in templates
|
||||
print("The following templates will be written:")
|
||||
for template_name, template_content in templates.items():
|
||||
|
||||
# It's possible to organize the role templates and their dependent
|
||||
# files into directories, in which case the template_name will
|
||||
# carry the directory information. If that's the case, first
|
||||
# create the directory structure (if it hasn't already been
|
||||
# created by another file in the templates list).
|
||||
template_dir = os.path.dirname(template_name)
|
||||
output_template_dir = os.path.join(output_dir, template_dir)
|
||||
if template_dir and not os.path.exists(output_template_dir):
|
||||
os.makedirs(output_template_dir)
|
||||
|
||||
filename = os.path.join(output_dir, template_name)
|
||||
with open(filename, 'w+') as template_file:
|
||||
template_file.write(template_content)
|
||||
print(filename)
|
||||
|
||||
overcloud_yaml = os.path.join(output_dir, 'plan.yaml')
|
||||
environment_yaml = os.path.join(output_dir, 'environment.yaml')
|
||||
|
||||
self._heat_deploy(stack, overcloud_yaml, None, [environment_yaml, ])
|
||||
|
||||
def _post_heat_deploy(self):
|
||||
"""Setup after the Heat stack create or update has been done."""
|
||||
|
Reference in New Issue
Block a user