Update necessary packages before undercloud upgarde.
This used to be a manual step in the tripleo process. You still have to update python-tripleoclient and tripleo-common manually. But: - "openstack-tripleo-heat-templates" - "openstack-tripleo-validations" - "tripleo-ansible" can all be installed from this process as we spawn another new process "openstack tripleo upgrade". Thus all those packages will be available for it. Note that tripleo-common should still be installed before running that command as some of its code is used by tripleoclient. Eventually adding version dependencies from python-tripleoclient to those other packages (or from tht which would stay a manual step) looks challenging as it would be hard to track which version work with which version. Change-Id: Ic258f314074007e7e5fd16d87448ffb7a3447fc3 Closes-Bug: #1869776
This commit is contained in:
parent
624a61f206
commit
0227a54473
|
@ -155,3 +155,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"
|
||||
]
|
||||
|
|
|
@ -581,7 +581,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,
|
||||
mock_getuid):
|
||||
|
@ -591,6 +593,13 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'dnf', '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',
|
||||
|
@ -648,7 +657,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,
|
||||
mock_getuid):
|
||||
|
@ -659,6 +670,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'dnf', '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',
|
||||
|
@ -714,7 +733,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,
|
||||
mock_getuid):
|
||||
|
@ -725,6 +746,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'dnf', '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',
|
||||
|
@ -780,7 +809,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_copy, mock_user,
|
||||
mock_getuid):
|
||||
|
@ -791,6 +822,14 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'dnf', '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',
|
||||
|
@ -847,7 +886,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,
|
||||
mock_getuid):
|
||||
|
@ -861,6 +902,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', 'dnf', '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', 'dnf', '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