containerized/undercloud: disable verbosity by default

By default, we were passing --debug when deploying the containerized
undercloud, but this is too much verbosity by default.

Instead, we'll allow the operator to pass --debug or --verbose when
they want verbosity:

  openstack undercloud install --use-heat --verbose
  openstack undercloud upgrade --use-heat --verbose

Change-Id: I807e3cacf224e58d2b96855e119ed0aaeebc5e26
Closes-Bug: #1669606
This commit is contained in:
Emilien Macchi 2018-04-05 10:50:56 -07:00 committed by Juan Antonio Osorio Robles
parent 8f87c8e361
commit 1db4335742
4 changed files with 123 additions and 8 deletions

View File

@ -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

View File

@ -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',

View File

@ -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:

View File

@ -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"]