diff --git a/releasenotes/notes/undercloud_debug-764ec17aa0653def.yaml b/releasenotes/notes/undercloud_debug-764ec17aa0653def.yaml new file mode 100644 index 000000000..c5e32b918 --- /dev/null +++ b/releasenotes/notes/undercloud_debug-764ec17aa0653def.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Verbosity is disabled by default when deploying or upgrading a containerized + undercloud; but it can be enabled with the option: --verbose diff --git a/tripleoclient/tests/v1/undercloud/test_undercloud.py b/tripleoclient/tests/v1/undercloud/test_undercloud.py index 96c74dd7b..78c7d38f3 100644 --- a/tripleoclient/tests/v1/undercloud/test_undercloud.py +++ b/tripleoclient/tests/v1/undercloud/test_undercloud.py @@ -38,7 +38,9 @@ class TestUndercloudInstall(TestPluginV1): conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) conf.config(container_images_file='/home/stack/foo.yaml') # Get the command object to test - self.cmd = undercloud.InstallUndercloud(self.app, None) + app_args = mock.Mock() + app_args.verbose_level = 1 + self.cmd = undercloud.InstallUndercloud(self.app, app_args) @mock.patch('subprocess.check_call', autospec=True) def test_undercloud_install(self, mock_subprocess): @@ -60,6 +62,55 @@ class TestUndercloudInstall(TestPluginV1): # DisplayCommandBase.take_action() returns two tuples self.cmd.take_action(parsed_args) + mock_subprocess.assert_called_with( + ['sudo', 'openstack', 'undercloud', + 'deploy', '--local-domain=localdomain', + '--local-ip=192.168.24.1/24', + '--templates=/usr/share/openstack-tripleo-heat-templates/', + '--heat-native', '-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/mistral.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/zaqar.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tripleo-ui.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/' + 'tls-endpoints-public-ip.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'use-dns-for-vips.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-haproxy.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-keepalived.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'docker.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'config-download-environment.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'undercloud.yaml', '-e', '/tmp/undercloud_parameters.yaml', + mock.ANY]) + + @mock.patch('subprocess.check_call', autospec=True) + def test_undercloud_install_with_heat_and_debug(self, mock_subprocess): + arglist = ['--use-heat', '--no-validations'] + verifylist = [] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # DisplayCommandBase.take_action() returns two tuples + old_verbose = self.cmd.app_args.verbose_level + self.cmd.app_args.verbose_level = 2 + self.cmd.take_action(parsed_args) + self.cmd.app_args.verbose_level = old_verbose + mock_subprocess.assert_called_with( ['sudo', 'openstack', 'undercloud', 'deploy', '--local-domain=localdomain', @@ -105,7 +156,9 @@ class TestUndercloudUpgrade(TestPluginV1): conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) conf.config(container_images_file='/home/stack/foo.yaml') # Get the command object to test - self.cmd = undercloud.UpgradeUndercloud(self.app, None) + app_args = mock.Mock() + app_args.verbose_level = 1 + self.cmd = undercloud.UpgradeUndercloud(self.app, app_args) @mock.patch('subprocess.check_call', autospec=True) def test_undercloud_upgrade(self, mock_subprocess): @@ -136,6 +189,58 @@ class TestUndercloudUpgrade(TestPluginV1): # DisplayCommandBase.take_action() returns two tuples self.cmd.take_action(parsed_args) + mock_subprocess.assert_called_with( + ['sudo', 'openstack', 'undercloud', + 'deploy', '--local-domain=localdomain', + '--local-ip=192.168.24.1/24', + '--templates=/usr/share/openstack-tripleo-heat-templates/', + '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'major-upgrade-composable-steps-docker.yaml', + '--heat-native', '-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/mistral.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/zaqar.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/tripleo-ui.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/' + 'tls-endpoints-public-ip.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'use-dns-for-vips.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-haproxy.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'services/undercloud-keepalived.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'docker.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'config-download-environment.yaml', '-e', + '/usr/share/openstack-tripleo-heat-templates/environments/' + 'undercloud.yaml', '-e', '/tmp/undercloud_parameters.yaml', + mock.ANY]) + + @mock.patch('subprocess.check_call', autospec=True) + def test_undercloud_upgrade_with_heat_and_debug(self, mock_subprocess): + arglist = ['--use-heat', '--no-validations'] + verifylist = [] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # DisplayCommandBase.take_action() returns two tuples + old_verbose = self.cmd.app_args.verbose_level + self.cmd.app_args.verbose_level = 2 + self.cmd.take_action(parsed_args) + self.cmd.app_args.verbose_level = old_verbose + mock_subprocess.assert_called_with( ['sudo', 'openstack', 'undercloud', 'deploy', '--local-domain=localdomain', diff --git a/tripleoclient/v1/undercloud.py b/tripleoclient/v1/undercloud.py index b47c89be8..4d4867ca9 100644 --- a/tripleoclient/v1/undercloud.py +++ b/tripleoclient/v1/undercloud.py @@ -68,7 +68,9 @@ class InstallUndercloud(command.Command): if parsed_args.use_heat: no_validations = parsed_args.dry_run or parsed_args.no_validations cmd = undercloud_config.\ - prepare_undercloud_deploy(no_validations=no_validations) + prepare_undercloud_deploy( + no_validations=no_validations, + verbose_level=self.app_args.verbose_level) else: cmd = ["instack-install-undercloud"] if parsed_args.dry_run: @@ -89,9 +91,11 @@ class UpgradeUndercloud(InstallUndercloud): utils.ensure_run_as_normal_user() if parsed_args.use_heat: cmd = undercloud_config.\ - prepare_undercloud_deploy(upgrade=True, - no_validations=parsed_args. - no_validations) + prepare_undercloud_deploy( + upgrade=True, + no_validations=parsed_args. + no_validations, + verbose_level=self.app_args.verbose_level) print("Running: %s" % ' '.join(cmd)) subprocess.check_call(cmd) else: diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 008140eb1..4e69d6e69 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -604,7 +604,8 @@ def _generate_masquerade_networks(): # return '\n '.join(env_list) -def prepare_undercloud_deploy(upgrade=False, no_validations=False): +def prepare_undercloud_deploy(upgrade=False, no_validations=False, + verbose_level=1): """Prepare Undercloud deploy command based on undercloud.conf""" env_data = {} @@ -801,7 +802,7 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False): if CONF.get('enable_validations') and not no_validations: undercloud_preflight.check() - if CONF.get('undercloud_debug', None): + if verbose_level > 1: deploy_args.append('--debug') cmd = ["sudo", "openstack", "undercloud", "deploy"]