Merge "Update necessary packages before undercloud upgarde." into stable/train
This commit is contained in:
commit
d2aac8af75
|
@ -166,3 +166,11 @@ UNUSED_PARAMETER_EXCLUDES_RE = ['^(Docker|Container).*Image$',
|
|||
EXPORT_PASSWORD_EXCLUDE_PATTERNS = [
|
||||
'ceph.*'
|
||||
]
|
||||
|
||||
# Package that need to be to the latest before undercloud
|
||||
# update/update/ffwd.
|
||||
UNDERCLOUD_EXTRA_PACKAGES = [
|
||||
"openstack-tripleo-heat-templates",
|
||||
"openstack-tripleo-validations",
|
||||
"tripleo-ansible"
|
||||
]
|
||||
|
|
|
@ -569,7 +569,9 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('os.mkdir')
|
||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_upgrade_default(self, mock_subprocess,
|
||||
@mock.patch('tripleoclient.utils.run_command', autospec=True)
|
||||
def test_undercloud_upgrade_default(self, mock_run_command,
|
||||
mock_subprocess,
|
||||
mock_wr,
|
||||
mock_os, mock_copy, mock_user):
|
||||
arglist = ['--no-validations']
|
||||
|
@ -578,6 +580,13 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'yum', 'upgrade', '-y',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with(
|
||||
['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy',
|
||||
|
@ -634,7 +643,9 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('os.mkdir')
|
||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_enabled(self, mock_subprocess,
|
||||
@mock.patch('tripleoclient.utils.run_command', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_enabled(self, mock_run_command,
|
||||
mock_subprocess,
|
||||
mock_wr, mock_os,
|
||||
mock_copy, mock_user):
|
||||
arglist = ['--no-validations']
|
||||
|
@ -644,6 +655,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'yum', 'upgrade', '-y',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with(
|
||||
['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy',
|
||||
'--standalone', '--standalone-role', 'Undercloud', '--stack',
|
||||
|
@ -698,7 +717,9 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('os.mkdir')
|
||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_true(self, mock_subprocess,
|
||||
@mock.patch('tripleoclient.utils.run_command', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_true(self, mock_run_command,
|
||||
mock_subprocess,
|
||||
mock_wr, mock_os,
|
||||
mock_copy, mock_user):
|
||||
arglist = ['--no-validations']
|
||||
|
@ -708,6 +729,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'yum', 'upgrade', '-y',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with(
|
||||
['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy',
|
||||
'--standalone', '--standalone-role', 'Undercloud', '--stack',
|
||||
|
@ -762,7 +791,9 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('os.mkdir')
|
||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_and_yes(self, mock_subprocess,
|
||||
@mock.patch('tripleoclient.utils.run_command', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_and_yes(self, mock_run_command,
|
||||
mock_subprocess,
|
||||
mock_wr, mock_os,
|
||||
mock_user, mock_copy):
|
||||
arglist = ['--no-validations', '-y']
|
||||
|
@ -772,6 +803,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'yum', 'upgrade', '-y',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with(
|
||||
['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy',
|
||||
'--standalone', '--standalone-role', 'Undercloud', '--stack',
|
||||
|
@ -827,7 +866,9 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('os.mkdir')
|
||||
@mock.patch('tripleoclient.utils.write_env_file', autospec=True)
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_and_debug(self, mock_subprocess,
|
||||
@mock.patch('tripleoclient.utils.run_command', autospec=True)
|
||||
def test_undercloud_upgrade_with_heat_and_debug(self, mock_run_command,
|
||||
mock_subprocess,
|
||||
mock_wr, mock_os,
|
||||
mock_copy, mock_user):
|
||||
arglist = ['--no-validations']
|
||||
|
@ -840,6 +881,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
self.cmd.take_action(parsed_args)
|
||||
self.cmd.app_args.verbose_level = old_verbose
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'yum', 'upgrade', '-y',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with(
|
||||
['sudo', '--preserve-env', 'openstack', 'tripleo', 'deploy',
|
||||
'--standalone', '--standalone-role', 'Undercloud', '--stack',
|
||||
|
|
|
@ -165,6 +165,29 @@ class UpgradeUndercloud(InstallUndercloud):
|
|||
log = logging.getLogger(__name__ + ".UpgradeUndercloud")
|
||||
osloconfig = cfg.CONF
|
||||
|
||||
def _update_extra_packages(self, packages=[], dry_run=False):
|
||||
"""Necessary packages to be updated before undercloud upgrade."""
|
||||
|
||||
cmd = []
|
||||
if packages:
|
||||
cmd = ['sudo', 'yum', 'upgrade', '-y'] + packages
|
||||
|
||||
if cmd:
|
||||
if not dry_run:
|
||||
self.log.warning(
|
||||
"Updating necessary packages: {}\n{}".format(
|
||||
" ".join(packages),
|
||||
("Note that tripleoclient and tripleo-common "
|
||||
"still need to be updated manually.")
|
||||
),
|
||||
)
|
||||
output = utils.run_command(cmd, name="Update extra packages")
|
||||
self.log.warning("{}".format(output))
|
||||
else:
|
||||
self.log.warning(
|
||||
"Would update necessary packages: {}".format(" ".join(cmd))
|
||||
)
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
# Fetch configuration used to add logging to a file
|
||||
utils.load_config(self.osloconfig, constants.UNDERCLOUD_CONF_PATH)
|
||||
|
@ -173,6 +196,10 @@ class UpgradeUndercloud(InstallUndercloud):
|
|||
self.log.debug("take action(%s)" % parsed_args)
|
||||
|
||||
utils.ensure_run_as_normal_user()
|
||||
|
||||
self._update_extra_packages(constants.UNDERCLOUD_EXTRA_PACKAGES,
|
||||
parsed_args.dry_run)
|
||||
|
||||
cmd = undercloud_config.\
|
||||
prepare_undercloud_deploy(
|
||||
upgrade=True,
|
||||
|
@ -182,6 +209,7 @@ 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)
|
||||
|
|
Loading…
Reference in New Issue