Merge "Add upgrade-[prepare|converge].yaml into upgrade cli"
This commit is contained in:
commit
322f533fcc
@ -34,7 +34,6 @@ DEFAULT_ENV_DIRECTORY = os.path.join(os.environ.get('HOME'),
|
||||
'.tripleo', 'environments')
|
||||
|
||||
TRIPLEO_PUPPET_MODULES = "/usr/share/openstack-puppet/modules/"
|
||||
UPGRADE_CONVERGE_FILE = "major-upgrade-converge-docker.yaml"
|
||||
PUPPET_MODULES = "/etc/puppet/modules/"
|
||||
PUPPET_BASE = "/etc/puppet/"
|
||||
# Update Queue
|
||||
@ -50,3 +49,7 @@ MAJOR_UPGRADE_PLAYBOOKS = ["upgrade_steps_playbook.yaml",
|
||||
"deploy_steps_playbook.yaml",
|
||||
"post_upgrade_steps_playbook.yaml"]
|
||||
MAJOR_UPGRADE_SKIP_TAGS = ['validation', 'pre-upgrade']
|
||||
# upgrade environment files expected by the client in the --templates
|
||||
# tripleo-heat-templates default above $TRIPLEO_HEAT_TEMPLATES
|
||||
UPGRADE_PREPARE_ENV = "environments/lifecycle/upgrade-prepare.yaml"
|
||||
UPGRADE_CONVERGE_ENV = "environments/lifecycle/upgrade-converge.yaml"
|
||||
|
@ -36,6 +36,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
|
||||
self.mock_uuid4 = uuid4_patcher.start()
|
||||
self.addCleanup(self.mock_uuid4.stop)
|
||||
|
||||
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.get_stack',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_upgrade.UpgradePrepare.log',
|
||||
@ -50,13 +51,14 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
|
||||
'_deploy_tripleo_heat_templates', autospec=True)
|
||||
def test_upgrade_out(self, mock_deploy, mock_open, mock_copy, mock_yaml,
|
||||
mock_abspath, mock_upgrade, mock_logger,
|
||||
mock_get_stack):
|
||||
mock_get_stack, add_env):
|
||||
mock_stack = mock.Mock()
|
||||
mock_stack.stack_name = 'mystack'
|
||||
mock_get_stack.return_value = mock_stack
|
||||
mock_abspath.return_value = '/home/fake/my-fake-registry.yaml'
|
||||
mock_yaml.return_value = {'fake_container': 'fake_value'}
|
||||
|
||||
add_env = mock.Mock()
|
||||
add_env.return_value = True
|
||||
argslist = ['--stack', 'overcloud', '--templates',
|
||||
'--container-registry-file', 'my-fake-registry.yaml']
|
||||
verifylist = [
|
||||
@ -75,6 +77,7 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
|
||||
'/site-docker.yml.sample'
|
||||
)
|
||||
|
||||
@mock.patch('tripleoclient.utils.prepend_environment', autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.package_update.update',
|
||||
autospec=True)
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@ -84,10 +87,12 @@ class TestOvercloudUpgradePrepare(fakes.TestOvercloudUpgradePrepare):
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates', autospec=True)
|
||||
def test_upgrade_failed(self, mock_deploy, mock_copy, mock_yaml,
|
||||
mock_abspath, mock_open, mock_upgrade):
|
||||
mock_abspath, mock_open, mock_upgrade, add_env):
|
||||
mock_upgrade.side_effect = exceptions.DeploymentError()
|
||||
mock_abspath.return_value = '/home/fake/my-fake-registry.yaml'
|
||||
mock_yaml.return_value = {'fake_container': 'fake_value'}
|
||||
add_env = mock.Mock()
|
||||
add_env.return_value = True
|
||||
argslist = ['--stack', 'overcloud', '--templates',
|
||||
'--container-registry-file', 'my-fake-registry.yaml']
|
||||
verifylist = [
|
||||
|
@ -929,3 +929,20 @@ def run_update_ansible_action(log, clients, nodes, inventory, playbook,
|
||||
action.update_ansible(clients, nodes=nodes, inventory_file=inventory,
|
||||
playbook=book, ansible_queue_name=queue,
|
||||
node_user=ssh_user, skip_tags=skip_tags)
|
||||
|
||||
|
||||
def prepend_environment(environment_files, templates_dir, environment):
|
||||
if not environment_files:
|
||||
environment_files = []
|
||||
|
||||
full_path = os.path.join(templates_dir, environment)
|
||||
# sanity check it exists before proceeding
|
||||
if os.path.exists(full_path):
|
||||
# We need to prepend before the files provided by user.
|
||||
environment_files.insert(0, full_path)
|
||||
else:
|
||||
raise exceptions.InvalidConfiguration(
|
||||
"Expected environment file %s not found in %s cannot proceed."
|
||||
% (environment, templates_dir))
|
||||
|
||||
return environment_files
|
||||
|
@ -82,6 +82,12 @@ class UpgradePrepare(DeployOvercloud):
|
||||
# update_plan_only. The heat stack update is done by the
|
||||
# packag_update mistral action
|
||||
parsed_args.update_plan_only = True
|
||||
# Add the upgrade-prepare.yaml environment to set noops etc
|
||||
templates_dir = (parsed_args.templates or
|
||||
constants.TRIPLEO_HEAT_TEMPLATES)
|
||||
parsed_args.environment_files = oooutils.prepend_environment(
|
||||
parsed_args.environment_files, templates_dir,
|
||||
constants.UPGRADE_PREPARE_ENV)
|
||||
super(UpgradePrepare, self).take_action(parsed_args)
|
||||
package_update.update(clients, container=stack_name,
|
||||
container_registry=registry,
|
||||
@ -218,6 +224,13 @@ class UpgradeConvergeOvercloud(DeployOvercloud):
|
||||
stack_name = stack.stack_name
|
||||
|
||||
parsed_args.update_plan_only = True
|
||||
# Add the converge environment into the args to unset noop etc
|
||||
templates_dir = (parsed_args.templates or
|
||||
constants.TRIPLEO_HEAT_TEMPLATES)
|
||||
parsed_args.environment_files = oooutils.prepend_environment(
|
||||
parsed_args.environment_files, templates_dir,
|
||||
constants.UPGRADE_CONVERGE_ENV)
|
||||
|
||||
super(UpgradeConvergeOvercloud, self).take_action(parsed_args)
|
||||
# Run converge steps
|
||||
package_update.converge_nodes(clients, container=stack_name)
|
||||
|
Loading…
Reference in New Issue
Block a user