Support '--tags' for 'overcloud upgrade run'

This will allow more specialized usage of upgrade run command, similar
to patterns used with 'external-upgrade run', e.g. during
reprovisioning of nodes.

Also, validation on '--skip-tags' is removed because we should no
longer assume what tags are defined by the upgrade tasks, and we
should allow more free-form usage.

Change-Id: Icf672cc0db50ea6daa57d3c5abe131c82553fc5a
Implements: blueprint upgrades-with-os
This commit is contained in:
Jiri Stransky 2019-01-15 13:56:13 +01:00
parent 500341c835
commit 78bf55c8ef
2 changed files with 44 additions and 2 deletions

View File

@ -207,6 +207,39 @@ class TestOvercloudUpgradeRun(fakes.TestOvercloudUpgradeRun):
verbosity=1
)
@mock.patch('tripleoclient.workflows.package_update.update_ansible',
autospec=True)
@mock.patch('os.path.expanduser')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('six.moves.builtins.open')
def test_upgrade_role_all_playbooks_only_validation(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--roles', 'Compute', '--playbook', 'all',
'--tags', 'validation']
verifylist = [
('roles', 'Compute'),
('static_inventory', None),
('playbook', 'all'),
('tags', 'validation')
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
with mock.patch('os.path.exists') as mock_exists:
mock_exists.return_value = True
self.cmd.take_action(parsed_args)
for book in constants.MAJOR_UPGRADE_PLAYBOOKS:
upgrade_ansible.assert_any_call(
self.app.client_manager,
nodes='Compute',
inventory_file=mock_open().read(),
playbook=book,
node_user='tripleo-admin',
tags='validation',
skip_tags='',
verbosity=1,
)
@mock.patch('tripleoclient.workflows.package_update.update_ansible',
autospec=True)
@mock.patch('os.path.expanduser')

View File

@ -166,6 +166,14 @@ class UpgradeRun(command.Command):
help=_("DEPRECATED: Only tripleo-admin should be "
"used as ssh user.")
)
parser.add_argument('--tags',
dest='tags',
action="store",
default="",
help=_('A string specifying the tag or comma '
'separated list of tags to be passed '
'as --tags to ansible-playbook.')
)
parser.add_argument('--skip-tags',
dest='skip_tags',
action="store",
@ -221,8 +229,9 @@ class UpgradeRun(command.Command):
constants.MAJOR_UPGRADE_PLAYBOOKS,
package_update,
parsed_args.ssh_user,
skip_tags=skip_tags,
verbosity=verbosity)
parsed_args.tags,
skip_tags,
verbosity)
playbooks = (constants.MAJOR_UPGRADE_PLAYBOOKS
if playbook == 'all' else playbook)