py3: Switch to using Python 3 for OpenStack Rocky
Switch nova installation to use Python 3 for OpenStack Rocky. Purge python- packages on upgrade. Change-Id: I7839c823d51f6a3d166157be19f2e93b8dd72305 Depends-On: Ic5e96336b6a2ca474fc28d358553c6a05e1a75ce
This commit is contained in:
parent
e5a8c29f4f
commit
280c0d7d96
|
@ -32,6 +32,9 @@ from charmhelpers.fetch import (
|
|||
apt_update,
|
||||
apt_upgrade,
|
||||
apt_install,
|
||||
apt_purge,
|
||||
apt_autoremove,
|
||||
filter_missing_packages,
|
||||
)
|
||||
|
||||
from charmhelpers.core.fstab import Fstab
|
||||
|
@ -126,6 +129,16 @@ BASE_PACKAGES = [
|
|||
'xfsprogs',
|
||||
]
|
||||
|
||||
PY3_PACKAGES = [
|
||||
'python3-nova',
|
||||
'python3-memcache',
|
||||
]
|
||||
|
||||
PURGE_PACKAGES = [
|
||||
'python-nova',
|
||||
'python-memcache',
|
||||
]
|
||||
|
||||
VERSION_PACKAGE = 'nova-common'
|
||||
|
||||
DEFAULT_INSTANCE_PATH = '/var/lib/nova/instances'
|
||||
|
@ -370,6 +383,9 @@ def determine_packages_arch():
|
|||
|
||||
|
||||
def determine_packages():
|
||||
release = os_release('nova-common')
|
||||
cmp_release = CompareOpenStackReleases(release)
|
||||
|
||||
packages = [] + BASE_PACKAGES
|
||||
|
||||
net_manager = network_manager()
|
||||
|
@ -393,9 +409,21 @@ def determine_packages():
|
|||
|
||||
packages.extend(determine_packages_arch())
|
||||
|
||||
if cmp_release >= 'rocky':
|
||||
packages = [p for p in packages if not p.startswith('python-')]
|
||||
packages.extend(PY3_PACKAGES)
|
||||
|
||||
return packages
|
||||
|
||||
|
||||
def determine_purge_packages():
|
||||
'''Return a list of packages to purge for the current OS release'''
|
||||
cmp_os_source = CompareOpenStackReleases(os_release('nova-common'))
|
||||
if cmp_os_source >= 'rocky':
|
||||
return PURGE_PACKAGES
|
||||
return []
|
||||
|
||||
|
||||
def migration_enabled():
|
||||
# XXX: confirm juju-core bool behavior is the same.
|
||||
return config('enable-live-migration')
|
||||
|
@ -568,6 +596,13 @@ def do_openstack_upgrade(configs):
|
|||
reset_os_release()
|
||||
apt_install(determine_packages(), fatal=True)
|
||||
|
||||
installed_packages = filter_missing_packages(
|
||||
determine_purge_packages()
|
||||
)
|
||||
if installed_packages:
|
||||
apt_purge(installed_packages, fatal=True)
|
||||
apt_autoremove(purge=True, fatal=True)
|
||||
|
||||
configs.set_release(openstack_release=new_os_rel)
|
||||
configs.write_all()
|
||||
if not is_unit_paused_set():
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -67,7 +67,7 @@ basepython = python2.7
|
|||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
bundletester -vl DEBUG -r json -o func-results.json gate-basic-bionic-queens --no-destroy
|
||||
bundletester -vl DEBUG -r json -o func-results.json gate-basic-bionic-rocky --no-destroy
|
||||
|
||||
[testenv:func27-dfs]
|
||||
# Charm Functional Test
|
||||
|
|
|
@ -39,6 +39,9 @@ VIRSH_NET_LIST = """ Name State Autostart Persistent
|
|||
TO_PATCH = [
|
||||
'apt_install',
|
||||
'apt_update',
|
||||
'apt_purge',
|
||||
'apt_autoremove',
|
||||
'filter_missing_packages',
|
||||
'config',
|
||||
'os_release',
|
||||
'log',
|
||||
|
@ -119,6 +122,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
@patch('platform.machine')
|
||||
def test_determine_packages_neutron(self, machine, net_man,
|
||||
n_plugin, en_meta):
|
||||
self.os_release.return_value = 'ocata'
|
||||
en_meta.return_value = (False, None)
|
||||
net_man.return_value = 'neutron'
|
||||
n_plugin.return_value = 'ovs'
|
||||
|
@ -128,6 +132,27 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
ex = utils.BASE_PACKAGES + ['nova-compute-kvm']
|
||||
self.assertTrue(ex == result)
|
||||
|
||||
@patch.object(utils, 'nova_metadata_requirement')
|
||||
@patch.object(utils, 'neutron_plugin')
|
||||
@patch.object(utils, 'network_manager')
|
||||
@patch('platform.machine')
|
||||
def test_determine_packages_neutron_rocky(self, machine, net_man,
|
||||
n_plugin, en_meta):
|
||||
self.os_release.return_value = 'rocky'
|
||||
en_meta.return_value = (False, None)
|
||||
net_man.return_value = 'neutron'
|
||||
n_plugin.return_value = 'ovs'
|
||||
machine.return_value = 'x86_64'
|
||||
self.relation_ids.return_value = []
|
||||
result = utils.determine_packages()
|
||||
ex = (
|
||||
[p for p in utils.BASE_PACKAGES
|
||||
if not p.startswith('python-')] +
|
||||
['nova-compute-kvm'] +
|
||||
utils.PY3_PACKAGES
|
||||
)
|
||||
self.assertEqual(ex, result)
|
||||
|
||||
@patch.object(utils, 'nova_metadata_requirement')
|
||||
@patch.object(utils, 'neutron_plugin')
|
||||
@patch.object(utils, 'network_manager')
|
||||
|
@ -135,6 +160,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
def test_determine_packages_neutron_aarch64_xenial(self, machine,
|
||||
net_man, n_plugin,
|
||||
en_meta):
|
||||
self.os_release.return_value = 'ocata'
|
||||
self.lsb_release.return_value = {
|
||||
'DISTRIB_CODENAME': 'xenial'
|
||||
}
|
||||
|
@ -154,6 +180,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
def test_determine_packages_neutron_aarch64_trusty(self, machine,
|
||||
net_man, n_plugin,
|
||||
en_meta):
|
||||
self.os_release.return_value = 'ocata'
|
||||
self.lsb_release.return_value = {
|
||||
'DISTRIB_CODENAME': 'trusty'
|
||||
}
|
||||
|
@ -172,6 +199,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
@patch('platform.machine')
|
||||
def test_determine_packages_neutron_ceph(self, machine,
|
||||
net_man, n_plugin, en_meta):
|
||||
self.os_release.return_value = 'ocata'
|
||||
en_meta.return_value = (False, None)
|
||||
net_man.return_value = 'neutron'
|
||||
n_plugin.return_value = 'ovs'
|
||||
|
@ -186,6 +214,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
@patch.object(utils, 'network_manager')
|
||||
def test_determine_packages_metadata(self, net_man,
|
||||
n_plugin, en_meta):
|
||||
self.os_release.return_value = 'ocata'
|
||||
en_meta.return_value = (True, None)
|
||||
net_man.return_value = 'bob'
|
||||
n_plugin.return_value = 'ovs'
|
||||
|
|
Loading…
Reference in New Issue