Fix package manager used during undercloud packages update
As described in the related bug we need to use dnf instead of yum for centos8 otherwise it fails in the undercloud packages update. I am using the python version to determine - py3 is dnf. As part of discussion here when dnf isn't available fall back to yum. Found as part of the work in [1]. Related-Bug: 1886837 [1] https://tree.taiga.io/project/tripleo-ci-board/task/1817 Change-Id: Idac62d37a19ee49f30936e20021a9dab5af40eec
This commit is contained in:
parent
2c6dc2f26a
commit
9c53cb3ef5
|
@ -575,6 +575,8 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
app_args.verbose_level = 1
|
||||
self.cmd = undercloud.UpgradeUndercloud(self.app, app_args)
|
||||
|
||||
@mock.patch('os.system')
|
||||
@mock.patch('sys.version_info')
|
||||
@mock.patch('tripleoclient.utils.prompt_user_for_confirmation',
|
||||
return_value=True)
|
||||
@mock.patch.object(sys, 'executable', 'python2')
|
||||
|
@ -587,14 +589,30 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
@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, mock_confirm):
|
||||
mock_subprocess, mock_wr,
|
||||
mock_os_mkdir, mock_copy, mock_user,
|
||||
mock_getuid, mock_confirm, mock_sys,
|
||||
mock_os_sys):
|
||||
arglist = ['--no-validations']
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
mock_sys.major = 3
|
||||
mock_os_sys.return_value = 0
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_run_command.assert_called_with(
|
||||
['sudo', 'dnf', 'upgrade', '-y',
|
||||
'python2-tripleoclient',
|
||||
'openstack-tripleo-common',
|
||||
'openstack-tripleo-heat-templates',
|
||||
'openstack-tripleo-validations',
|
||||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
mock_os_sys.assert_called_with("which dnf")
|
||||
|
||||
mock_sys.major = 2
|
||||
# DisplayCommandBase.take_action() returns two tuples
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_run_command.assert_called_with(
|
||||
|
@ -606,6 +624,7 @@ class TestUndercloudUpgrade(TestPluginV1):
|
|||
'tripleo-ansible'],
|
||||
name='Update extra packages'
|
||||
)
|
||||
|
||||
mock_subprocess.assert_called_with([
|
||||
'openstack', 'undercloud', 'upgrade', '--skip-package-updates',
|
||||
'--no-validations'])
|
||||
|
|
|
@ -183,7 +183,11 @@ class UpgradeUndercloud(InstallUndercloud):
|
|||
if not packages:
|
||||
return
|
||||
|
||||
cmd = ['sudo', 'yum', 'upgrade', '-y'] + packages
|
||||
pkg_manager = 'yum'
|
||||
if sys.version_info.major >= 3 and os.system('which dnf') == 0:
|
||||
pkg_manager = 'dnf'
|
||||
|
||||
cmd = ['sudo', pkg_manager, 'upgrade', '-y'] + packages
|
||||
|
||||
if not dry_run:
|
||||
self.log.warning("Updating necessary packages: {}".format(
|
||||
|
|
Loading…
Reference in New Issue