Allow to use any repository in openstack-origin to upgrade
do_openstack_upgrade() assumes that a cloud archive repository will be used to upgrade the unit, this is not true for environments where a mirror is used or a PPA. Change-Id: I96a20e926f42dc5df4ddb3cb7ac5428b882711e8 Closes-Bug: #1646884
This commit is contained in:
parent
dfd8208354
commit
020e22eeae
@ -473,14 +473,16 @@ def get_step_upgrade_source(new_src):
|
||||
# NOTE: cur_pocket == * means all upgrades to target_src must step
|
||||
# through step_src if step_src is higher than
|
||||
# current release
|
||||
'cloud:precise-icehouse':
|
||||
('precise-updates/grizzly', 'cloud:precise-havana'),
|
||||
'cloud:precise-icehouse/proposed':
|
||||
('precise-proposed/grizzly', 'cloud:precise-havana/proposed'),
|
||||
'cloud:trusty-liberty': ('*', 'cloud:trusty-kilo'),
|
||||
'precise-icehouse': ('precise-updates/grizzly',
|
||||
'cloud:precise-havana'),
|
||||
'precise-icehouse/proposed': ('precise-proposed/grizzly',
|
||||
'cloud:precise-havana/proposed'),
|
||||
'trusty-liberty': ('*', 'cloud:trusty-kilo'),
|
||||
}
|
||||
try:
|
||||
cur_pocket, step_src = sources[new_src]
|
||||
os_codename = get_os_codename_install_source(new_src)
|
||||
ubuntu_series = lsb_release()['DISTRIB_CODENAME'].lower()
|
||||
cur_pocket, step_src = sources['%s-%s' % (ubuntu_series, os_codename)]
|
||||
current_src = os_release('nova-common')
|
||||
step_src_codename = get_os_codename_install_source(step_src)
|
||||
if cur_pocket == '*' and step_src_codename > current_src:
|
||||
@ -490,13 +492,23 @@ def get_step_upgrade_source(new_src):
|
||||
|
||||
configure_installation_source(new_src)
|
||||
|
||||
with open('/etc/apt/sources.list.d/cloud-archive.list', 'r') as f:
|
||||
line = f.readline()
|
||||
for target_src, (cur_pocket, step_src) in sources.items():
|
||||
if target_src != new_src:
|
||||
continue
|
||||
if cur_pocket in line:
|
||||
return step_src
|
||||
# charmhelpers.contrib.openstack.utils.configure_installation_source()
|
||||
# configures the repository in juju_deb.list, while
|
||||
# charmhelpers.fetch.add_sources() uses cloud-archive.list, so both
|
||||
# files need to read looking for the currently configured repo.
|
||||
for fname in ['cloud-archive.list', 'juju_deb.list']:
|
||||
fpath = os.path.join('/etc/apt/sources.list.d/', fname)
|
||||
if not os.path.isfile(fpath):
|
||||
log('Missing %s skipping it' % fpath, level=DEBUG)
|
||||
continue
|
||||
|
||||
with open(fpath, 'r') as f:
|
||||
line = f.readline()
|
||||
for target_src, (cur_pocket, step_src) in sources.items():
|
||||
if target_src != new_src:
|
||||
continue
|
||||
if cur_pocket in line:
|
||||
return step_src
|
||||
|
||||
return None
|
||||
|
||||
@ -610,8 +622,6 @@ def database_setup(prefix):
|
||||
|
||||
def do_openstack_upgrade(configs):
|
||||
new_src = config('openstack-origin')
|
||||
if new_src[:6] != 'cloud:':
|
||||
raise ValueError("Unable to perform upgrade to %s" % new_src)
|
||||
|
||||
step_src = get_step_upgrade_source(new_src)
|
||||
if step_src is not None:
|
||||
|
@ -121,6 +121,35 @@ DPKG_OPTS = [
|
||||
'--option', 'Dpkg::Options::=--force-confdef',
|
||||
]
|
||||
|
||||
GPG_PPA_CLOUD_ARCHIVE = """-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: SKS 1.1.6
|
||||
Comment: Hostname: keyserver.ubuntu.com
|
||||
|
||||
mI0EUCEyTAEEAMuUxyfiegCCwn4J/c0nw5PUTSJdn5FqiUTq6iMfij65xf1vl0g/Mxqw0gfg
|
||||
AJIsCDvO9N9dloLAwF6FUBMg5My7WyhRPTAKF505TKJboyX3Pp4J1fU1LV8QFVOp87vUh1Rz
|
||||
B6GU7cSglhnbL85gmbJTllkzkb3h4Yw7W+edjcQ/ABEBAAG0K0xhdW5jaHBhZCBQUEEgZm9y
|
||||
IFVidW50dSBDbG91ZCBBcmNoaXZlIFRlYW2IuAQTAQIAIgUCUCEyTAIbAwYLCQgHAwIGFQgC
|
||||
CQoLBBYCAwECHgECF4AACgkQimhEop9oEE7kJAP/eTBgq3Mhbvo0d8elMOuqZx3nmU7gSyPh
|
||||
ep0zYIRZ5TJWl/7PRtvp0CJA6N6ZywYTQ/4ANHhpibcHZkh8K0AzUvsGXnJRSFoJeqyDbD91
|
||||
EhoO+4ZfHs2HvRBQEDZILMa2OyuB497E5Mmyua3HDEOrG2cVLllsUZzpTFCx8NgeMHk=
|
||||
=jLBm
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
"""
|
||||
|
||||
# ppa:ubuntu-cloud-archive/newton-staging
|
||||
OS_ORIGIN_NEWTON_STAGING = """deb http://ppa.launchpad.net/\
|
||||
ubuntu-cloud-archive/newton-staging/ubuntu xenial main
|
||||
|
|
||||
%s
|
||||
""" % GPG_PPA_CLOUD_ARCHIVE
|
||||
|
||||
# ppa:ubuntu-cloud-archive/liberty-staging
|
||||
OS_ORIGIN_LIBERTY_STAGING = """deb http://ppa.launchpad.net/\
|
||||
ubuntu-cloud-archive/liberty-staging/ubuntu trusty main
|
||||
|
|
||||
%s
|
||||
""" % GPG_PPA_CLOUD_ARCHIVE
|
||||
|
||||
openstack_origin_git = \
|
||||
"""repositories:
|
||||
- {name: requirements,
|
||||
@ -341,22 +370,56 @@ class NovaCCUtilsTests(CharmTestCase):
|
||||
utils.save_script_rc()
|
||||
self._save_script_rc.called_with(**SCRIPTRC_ENV_VARS)
|
||||
|
||||
def test_get_step_upgrade_source_target_liberty(self):
|
||||
self.get_os_codename_install_source.return_value = 'kilo'
|
||||
@patch('charmhelpers.contrib.openstack.utils.lsb_release')
|
||||
def test_get_step_upgrade_source_target_liberty(self, lsb_release):
|
||||
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
|
||||
lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
|
||||
self.get_os_codename_install_source.side_effect = self.originals[
|
||||
'get_os_codename_install_source']
|
||||
|
||||
# icehouse -> liberty
|
||||
self.os_release.return_value = 'icehouse'
|
||||
self.assertEquals(
|
||||
utils.get_step_upgrade_source('cloud:trusty-liberty'),
|
||||
'cloud:trusty-kilo')
|
||||
|
||||
# juno -> liberty
|
||||
self.os_release.return_value = 'juno'
|
||||
self.assertEquals(
|
||||
utils.get_step_upgrade_source('cloud:trusty-liberty'),
|
||||
'cloud:trusty-kilo')
|
||||
|
||||
# kilo -> liberty
|
||||
self.os_release.return_value = 'kilo'
|
||||
with patch_open() as (_open, _file):
|
||||
self.assertEquals(
|
||||
utils.get_step_upgrade_source('cloud:trusty-liberty'),
|
||||
None)
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.utils.lsb_release')
|
||||
def test_get_setup_upgrade_source_target_newton(self, lsb_release):
|
||||
# mitaka -> newton
|
||||
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
|
||||
lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
|
||||
self.os_release.return_value = 'mitaka'
|
||||
self.get_os_codename_install_source.side_effect = self.originals[
|
||||
'get_os_codename_install_source']
|
||||
|
||||
step_src = utils.get_step_upgrade_source(OS_ORIGIN_NEWTON_STAGING)
|
||||
self.assertEqual(step_src, None)
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.utils.lsb_release')
|
||||
def test_get_setup_upgrade_source_target_liberty_with_mirror(self,
|
||||
lsb_release):
|
||||
# from icehouse to liberty using a raw deb repo
|
||||
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
|
||||
lsb_release.return_value = {'DISTRIB_CODENAME': 'trusty'}
|
||||
self.get_os_codename_install_source.side_effect = self.originals[
|
||||
'get_os_codename_install_source']
|
||||
self.os_release.return_value = 'icehouse'
|
||||
step_src = utils.get_step_upgrade_source(OS_ORIGIN_LIBERTY_STAGING)
|
||||
self.assertEqual(step_src, 'cloud:trusty-kilo')
|
||||
|
||||
@patch.object(utils, 'remove_known_host')
|
||||
@patch.object(utils, 'ssh_known_host_key')
|
||||
@patch('subprocess.check_output')
|
||||
|
@ -63,6 +63,7 @@ class CharmTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self, obj, patches):
|
||||
super(CharmTestCase, self).setUp()
|
||||
self.originals = {}
|
||||
self.patches = patches
|
||||
self.obj = obj
|
||||
self.test_config = TestConfig()
|
||||
@ -70,6 +71,7 @@ class CharmTestCase(unittest.TestCase):
|
||||
self.patch_all()
|
||||
|
||||
def patch(self, method):
|
||||
self.originals[method] = getattr(self.obj, method)
|
||||
_m = patch.object(self.obj, method)
|
||||
mock = _m.start()
|
||||
self.addCleanup(_m.stop)
|
||||
|
Loading…
Reference in New Issue
Block a user