diff --git a/tripleoclient/tests/v1/undercloud/test_install_upgrade.py b/tripleoclient/tests/v1/undercloud/test_install_upgrade.py index 733fbb9d6..32f21041a 100644 --- a/tripleoclient/tests/v1/undercloud/test_install_upgrade.py +++ b/tripleoclient/tests/v1/undercloud/test_install_upgrade.py @@ -567,10 +567,47 @@ class TestUndercloudUpgrade(TestPluginV1): 'tripleo-ansible'], name='Update extra packages' ) - - mock_subprocess.assert_called_with([ - 'openstack', 'undercloud', 'upgrade', '--skip-package-updates', - '--no-validations']) + mock_subprocess.assert_called_with( + ['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy', + '--standalone', '--standalone-role', 'Undercloud', '--stack', + 'undercloud', '--local-domain=localdomain', + '--local-ip=192.168.24.1/24', + '--templates=/usr/share/openstack-tripleo-heat-templates/', + '--networks-file=/usr/share/openstack-tripleo-heat-templates/' + 'network_data_undercloud.yaml', + '--upgrade', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'lifecycle/undercloud-upgrade-prepare.yaml', + '--heat-native', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'undercloud.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'use-dns-for-vips.yaml', '-e', + '/home/stack/foo.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/ironic-inspector.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-remove-novajoin.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'disable-telemetry.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'public-tls-undercloud.yaml', + '--public-virtual-ip', '192.168.24.2', + '--control-virtual-ip', '192.168.24.3', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'ssl/tls-endpoints-public-ip.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-haproxy.yaml', + # TODO(cjeanner) drop once we have proper oslo.privsep + '--deployment-user', 'stack', + '--output-dir=/home/stack', '--cleanup', + '-e', '/home/stack/tripleo-config-generated-env-files/' + 'undercloud_parameters.yaml', + '--log-file=install-undercloud.log', '-e', + '/usr/share/openstack-tripleo-heat-templates/' + 'undercloud-stack-vstate-dropin.yaml']) @mock.patch.object(sys, 'executable', 'python3') # TODO(cjeanner) drop once we have proper oslo.privsep @@ -595,10 +632,7 @@ class TestUndercloudUpgrade(TestPluginV1): # DisplayCommandBase.take_action() returns two tuples self.cmd.take_action(parsed_args) mock_run_command.assert_not_called() - mock_subprocess.assert_called_with([ - 'openstack', 'undercloud', 'upgrade', '--skip-package-updates', - '--force-stack-update', '--no-validations', - '--inflight-validations', '--dry-run', '--yes', '--debug']) + mock_subprocess.assert_not_called() @mock.patch('tripleoclient.utils.prompt_user_for_confirmation', return_value=True) diff --git a/tripleoclient/v1/undercloud.py b/tripleoclient/v1/undercloud.py index b8bfb67af..5fe20fb43 100644 --- a/tripleoclient/v1/undercloud.py +++ b/tripleoclient/v1/undercloud.py @@ -205,26 +205,6 @@ class UpgradeUndercloud(InstallUndercloud): self.log.warning("Would update necessary packages: {}".format( " ".join(cmd))) - def _invoke_self(self, parsed_args): - cmd = ['openstack', 'undercloud', 'upgrade', '--skip-package-updates'] - opts = {'force_stack_update': '--force-stack-update', - 'no_validations': '--no-validations', - 'inflight': '--inflight-validations', - 'dry_run': '--dry-run', - 'yes': '--yes'} - args = vars(parsed_args) - for k, v in opts.items(): - if args[k]: - cmd.append(v) - # handle --debug - if self.app_args.verbose_level > 1: - cmd.append('--debug') - try: - subprocess.check_call(cmd) - except Exception as e: - self.log.error(e) - raise exceptions.DeploymentError(e) - def _run_upgrade(self, parsed_args): cmd = undercloud_config.\ prepare_undercloud_deploy( @@ -235,21 +215,19 @@ class UpgradeUndercloud(InstallUndercloud): verbose_level=self.app_args.verbose_level, force_stack_update=parsed_args.force_stack_update) self.log.warning("Running: %s" % ' '.join(cmd)) - - if not parsed_args.dry_run: - try: - subprocess.check_call(cmd) - self.log.warning( - UNDERCLOUD_UPGRADE_COMPLETION_MESSAGE.format( - os.path.join( - constants.UNDERCLOUD_OUTPUT_DIR, - 'undercloud-passwords.conf' - ), - '~/stackrc')) - except Exception as e: - self.log.error(UNDERCLOUD_FAILURE_MESSAGE) - self.log.error(e) - raise exceptions.DeploymentError(e) + try: + subprocess.check_call(cmd) + self.log.warning( + UNDERCLOUD_UPGRADE_COMPLETION_MESSAGE.format( + os.path.join( + constants.UNDERCLOUD_OUTPUT_DIR, + 'undercloud-passwords.conf' + ), + '~/stackrc')) + except Exception as e: + self.log.error(UNDERCLOUD_FAILURE_MESSAGE) + self.log.error(e) + raise exceptions.DeploymentError(e) def take_action(self, parsed_args): # Fetch configuration used to add logging to a file @@ -276,6 +254,6 @@ class UpgradeUndercloud(InstallUndercloud): ] pkgs = client_pkgs + constants.UNDERCLOUD_EXTRA_PACKAGES self._update_extra_packages(pkgs, parsed_args.dry_run) - self._invoke_self(parsed_args) - else: + + if not parsed_args.dry_run: self._run_upgrade(parsed_args)