Fix use of ``openstack-release`` to determine codename
The current code will oportunisticly attempt to install the ``openstack-release`` package, but it does so without configuring the UCA sources. Attempt to configure sources to avoid charms getting stuck in a chicken and egg situation. Closes-Bug: #1951462 Change-Id: I8ed6e2dfc7ce83c2e56fd072458e2ef189968e41
This commit is contained in:
parent
dda431eaf9
commit
55cc044ea8
|
@ -1204,11 +1204,17 @@ class BaseOpenStackCharmActions(object):
|
|||
:raises: AttributeError, ValueError
|
||||
"""
|
||||
|
||||
try:
|
||||
# The purpose of the UCA ``openstack-release`` package is to
|
||||
# relieve the charm and test code from maintining version maps.
|
||||
#
|
||||
# The ``get_installed_os_version`` helper will attempt to install
|
||||
# it, and that can only happen if the UCA is configured first.
|
||||
self.configure_source()
|
||||
codename = os_utils.get_installed_os_version()
|
||||
if codename:
|
||||
return codename
|
||||
|
||||
try:
|
||||
vers = self.get_package_version(
|
||||
package,
|
||||
apt_cache_sufficient=apt_cache_sufficient)
|
||||
|
|
|
@ -902,12 +902,14 @@ class TestMyOpenStackCharm(BaseOpenStackCharmTest):
|
|||
self.patch_object(chm_core.os_utils, 'get_installed_os_version')
|
||||
self.get_installed_os_version.return_value = None
|
||||
self.upstream_version.return_value = '3.0.0~b1'
|
||||
self.patch_object(self.target, 'configure_source')
|
||||
self.assertEqual(
|
||||
self.target.get_os_codename_package(
|
||||
'testpkg', codenames),
|
||||
'newton')
|
||||
self.upstream_version.assert_called_once_with(
|
||||
pkg_mock.current_ver.ver_str)
|
||||
self.configure_source.assert_called_once()
|
||||
self.upstream_version.reset_mock()
|
||||
self.assertEqual(
|
||||
self.target.get_os_codename_package(
|
||||
|
|
Loading…
Reference in New Issue