Add -y option to "openstack undercloud upgrade"

It was added to "openstack tripleo upgrade" but wasn't working for the
undercloud, so adding it and we will use it when upgrading the
undercloud without prompt.

Change-Id: Ib034765639667f49d4bfd92a2186ff5f022a938d
This commit is contained in:
Emilien Macchi 2018-05-22 15:39:06 -07:00
parent b6404d4f59
commit 9cc04d25f3
3 changed files with 64 additions and 1 deletions

View File

@ -480,6 +480,62 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud_parameters.yaml',
'--log-file=/tmp/install-undercloud.log'])
@mock.patch('os.mkdir')
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
@mock.patch('os.getcwd', return_value='/tmp')
@mock.patch('subprocess.check_call', autospec=True)
def test_undercloud_upgrade_with_heat_and_yes(self, mock_subprocess,
mock_cwd, mock_wr, mock_os):
arglist = ['--use-heat', '--no-validations', '-y']
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# DisplayCommandBase.take_action() returns two tuples
self.cmd.take_action(parsed_args)
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'-y', '--upgrade', '-e',
'/usr/share/openstack-tripleo-heat-templates/environments/'
'lifecycle/undercloud-upgrade-prepare.yaml',
'--heat-native', '-e',
'/usr/share/openstack-tripleo-heat-templates/environments/'
'docker.yaml', '-e',
'/usr/share/openstack-tripleo-heat-templates/environments/'
'undercloud.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/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/'
'services/tempest.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/'
'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',
'--output-dir=/home/stack', '--cleanup',
'-e', '/home/stack/tripleo-heat-installer-templates/'
'undercloud_parameters.yaml',
'--log-file=/tmp/install-undercloud.log'])
@mock.patch('os.mkdir')
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
@mock.patch('os.getcwd', return_value='/tmp')

View File

@ -59,6 +59,9 @@ class InstallUndercloud(command.Command):
default=False,
help=_("Print the install command instead of running it"),
)
parser.add_argument('-y', '--yes', default=False,
action='store_true',
help=_("Skip yes/no prompt (assume yes)."))
return parser
def take_action(self, parsed_args):
@ -95,6 +98,7 @@ class UpgradeUndercloud(InstallUndercloud):
cmd = undercloud_config.\
prepare_undercloud_deploy(
upgrade=True,
yes=parsed_args.yes,
no_validations=parsed_args.
no_validations,
verbose_level=self.app_args.verbose_level)

View File

@ -263,7 +263,7 @@ def _generate_masquerade_networks():
def prepare_undercloud_deploy(upgrade=False, no_validations=False,
verbose_level=1):
verbose_level=1, yes=False):
"""Prepare Undercloud deploy command based on undercloud.conf"""
env_data = {}
@ -331,6 +331,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
if CONF.get('roles_file', None):
deploy_args.append('--roles-file=%s' % CONF['roles_file'])
if yes:
deploy_args += ['-y']
if upgrade:
deploy_args += [
'--upgrade',