Refactor, fix ansible inventory method parameters for ffwd-upgrade run

This submission had the correct fix for the bug 1769867.

[0] was accidentaly stepping over this submission
to fix the parameter configuration. Still we need
the fix for configuring the parameters correctly
also fixing the unit tests.

The method parameters wasn't being passed into the
tripleo ansible inventory generation.
Also discussed in [1].

Related-Bug: 1769867
[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1575445
[0]: https://review.openstack.org/#/c/566960/
(cherry picked from commit d0673159e0)
Change-Id: I7c5347ef31aa002f22bcaa60fcbfff058ae8acb9
This commit is contained in:
mandreou 2018-05-08 14:16:08 +03:00 committed by Carlos Camacho
parent c7b7b4e3dc
commit 245eb695fb
2 changed files with 30 additions and 5 deletions

View File

@ -149,8 +149,8 @@ class TestFFWDUpgradeRun(fakes.TestFFWDUpgradeRun):
def test_ffwd_upgrade_playbook(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--yes']
verifylist = [('yes', True), ]
argslist = ['--ssh-user', 'heat-admin', '--yes']
verifylist = [('ssh_user', 'heat-admin'), ('yes', True), ]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
with mock.patch('os.path.exists') as mock_exists:
@ -166,6 +166,31 @@ class TestFFWDUpgradeRun(fakes.TestFFWDUpgradeRun):
skip_tags=''
)
@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_ffwd_upgrade_playbook_non_default_user(
self, mock_open, mock_execute, mock_expanduser, upgrade_ansible):
mock_expanduser.return_value = '/home/fake/'
argslist = ['--ssh-user', 'my-user', '--yes']
verifylist = [('ssh_user', 'my-user'), ('yes', True), ]
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)
upgrade_ansible.assert_called_once_with(
self.app.client_manager,
inventory_file=mock_open().read(),
ansible_queue_name=constants.FFWD_UPGRADE_QUEUE,
nodes='',
playbook=constants.FFWD_UPGRADE_PLAYBOOK,
node_user='my-user',
skip_tags=''
)
@mock.patch('tripleoclient.workflows.package_update.update_ansible',
autospec=True)
@mock.patch('os.path.expanduser')

View File

@ -147,11 +147,11 @@ class FFWDUpgradeRun(command.Command):
oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log)
clients = self.app.client_manager
stack = parsed_args.stack
ssh_user = parsed_args.ssh_user
# Run ansible:
inventory = oooutils.get_tripleo_ansible_inventory(
parsed_args.static_inventory, ssh_user, stack)
inventory_file=parsed_args.static_inventory,
ssh_user=parsed_args.ssh_user, stack=parsed_args.stack)
# Don't expost limit_hosts. We need this on the whole overcloud.
limit_hosts = ''
oooutils.run_update_ansible_action(