Remove detection of package manager for undercloud upgrade

In [1] we added protection for yum not being available.
We should just default to dnf for anything newer than
ussuri.

[1] 9c53cb3ef5

Change-Id: I5056579ae117c46944f20868c5cd1edfc1b86036
(cherry picked from commit 4a07e16a58)
This commit is contained in:
MSA 2020-10-30 18:11:24 +02:00 committed by wes hayutin
parent 9efc5faa51
commit 77abd0acb4
2 changed files with 2 additions and 25 deletions

View File

@ -575,8 +575,6 @@ 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')
@ -591,14 +589,11 @@ class TestUndercloudUpgrade(TestPluginV1):
def test_undercloud_upgrade_default(self, mock_run_command,
mock_subprocess, mock_wr,
mock_os_mkdir, mock_copy, mock_user,
mock_getuid, mock_confirm, mock_sys,
mock_os_sys):
mock_getuid, mock_confirm):
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(
@ -610,20 +605,6 @@ class TestUndercloudUpgrade(TestPluginV1):
'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(
['sudo', 'yum', 'upgrade', '-y',
'python2-tripleoclient',
'openstack-tripleo-common',
'openstack-tripleo-heat-templates',
'openstack-tripleo-validations',
'tripleo-ansible'],
name='Update extra packages'
)
mock_subprocess.assert_called_with([
'openstack', 'undercloud', 'upgrade', '--skip-package-updates',

View File

@ -183,11 +183,7 @@ class UpgradeUndercloud(InstallUndercloud):
if not packages:
return
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
cmd = ['sudo', 'dnf', 'upgrade', '-y'] + packages
if not dry_run:
self.log.warning("Updating necessary packages: {}".format(