py3: Switch to using Python 3 for rocky or later
Switch package install to Python 3 for OpenStack Rocky or later. When upgrading, remove any python-* packages that were explicitly installated and then autoremove --purge any dependencies that are no longer required. Change-Id: I87ee4a0a854f88b931093f6245a3a1057bf56c57
This commit is contained in:
parent
55a4fd3cdd
commit
d5c5cccb0a
|
@ -58,8 +58,11 @@ from charmhelpers.fetch import (
|
|||
apt_upgrade,
|
||||
apt_update,
|
||||
apt_install,
|
||||
apt_purge,
|
||||
apt_autoremove,
|
||||
add_source,
|
||||
filter_installed_packages
|
||||
filter_installed_packages,
|
||||
filter_missing_packages,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
|
@ -132,6 +135,16 @@ BASE_PACKAGES = [
|
|||
'python-psutil',
|
||||
'python-six',
|
||||
'python-memcache',
|
||||
'uuid',
|
||||
]
|
||||
|
||||
PY3_PACKAGES = [
|
||||
'libapache2-mod-wsgi-py3',
|
||||
'python3-nova',
|
||||
'python3-keystoneclient',
|
||||
'python3-psutil',
|
||||
'python3-six',
|
||||
'python3-memcache',
|
||||
]
|
||||
|
||||
VERSION_PACKAGE = 'nova-common'
|
||||
|
@ -442,7 +455,7 @@ def console_attributes(attr, proto=None):
|
|||
|
||||
def determine_packages():
|
||||
# currently all packages match service names
|
||||
cmp_os_release = CompareOpenStackReleases(os_release('nova-common'))
|
||||
release = CompareOpenStackReleases(os_release('nova-common'))
|
||||
packages = deepcopy(BASE_PACKAGES)
|
||||
for v in resource_map(actual_services=False).values():
|
||||
packages.extend(v['services'])
|
||||
|
@ -455,13 +468,32 @@ def determine_packages():
|
|||
pass
|
||||
if console_attributes('packages'):
|
||||
packages.extend(console_attributes('packages'))
|
||||
if (config('enable-serial-console') and cmp_os_release >= 'juno'):
|
||||
if (config('enable-serial-console') and release >= 'juno'):
|
||||
packages.extend(SERIAL_CONSOLE['packages'])
|
||||
|
||||
packages.extend(token_cache_pkgs(source=config('openstack-origin')))
|
||||
if release >= 'rocky':
|
||||
packages = [p for p in packages if not p.startswith('python-')]
|
||||
packages.extend(PY3_PACKAGES)
|
||||
packages.remove('libapache2-mod-wsgi')
|
||||
|
||||
return list(set(packages))
|
||||
|
||||
|
||||
def determine_purge_packages():
|
||||
'''
|
||||
Determine list of packages that where previously installed which are no
|
||||
longer needed.
|
||||
|
||||
:returns: list of package names
|
||||
'''
|
||||
release = CompareOpenStackReleases(os_release('keystone'))
|
||||
if release >= 'rocky':
|
||||
pkgs = [p for p in BASE_PACKAGES if p.startswith('python-')]
|
||||
pkgs.extend(['python-nova', 'python-memcache', 'libapache2-mod-wsgi'])
|
||||
return pkgs
|
||||
return []
|
||||
|
||||
|
||||
def save_script_rc():
|
||||
env_vars = {
|
||||
'OPENSTACK_PORT_MCASTPORT': config('ha-mcastport'),
|
||||
|
@ -611,6 +643,11 @@ def _do_openstack_upgrade(new_src):
|
|||
reset_os_release()
|
||||
apt_install(determine_packages(), fatal=True)
|
||||
|
||||
installed_pkgs = filter_missing_packages(determine_purge_packages())
|
||||
if installed_pkgs:
|
||||
apt_purge(installed_pkgs, fatal=True)
|
||||
apt_autoremove(purge=True, fatal=True)
|
||||
|
||||
disable_policy_rcd()
|
||||
|
||||
# NOTE(jamespage) upgrade with existing config files as the
|
||||
|
|
|
@ -637,131 +637,6 @@ class NovaCCBasicDeployment(OpenStackAmuletDeployment):
|
|||
message = u.relation_error('glance image-service', ret)
|
||||
amulet.raise_status(amulet.FAIL, msg=message)
|
||||
|
||||
def test_300_nova_default_config(self):
|
||||
"""Verify the data in the nova config file's default section."""
|
||||
u.log.debug('Checking nova config file data...')
|
||||
unit = self.nova_cc_sentry
|
||||
conf = '/etc/nova/nova.conf'
|
||||
|
||||
rmq_ncc_rel = self.rabbitmq_sentry.relation(
|
||||
'amqp', 'nova-cloud-controller:amqp')
|
||||
|
||||
gl_ncc_rel = self.glance_sentry.relation(
|
||||
'image-service', 'nova-cloud-controller:image-service')
|
||||
|
||||
# Since >= liberty endpoint_type was replaced by interface
|
||||
# https://github.com/openstack/keystoneauth/commit/d227f6d237c4309b21a32a115fc5b09b9ba46ef0
|
||||
try:
|
||||
ks_ep = self.keystone.service_catalog.url_for(
|
||||
service_type='identity', interface='publicURL')
|
||||
except TypeError:
|
||||
ks_ep = self.keystone.service_catalog.url_for(
|
||||
service_type='identity', endpoint_type='publicURL')
|
||||
|
||||
ks_ec2 = "{}/ec2tokens".format(ks_ep)
|
||||
|
||||
db_ncc_rel = self.pxc_sentry.relation(
|
||||
'shared-db', 'nova-cloud-controller:shared-db')
|
||||
|
||||
db_uri = "mysql://{}:{}@{}/{}".format('nova',
|
||||
db_ncc_rel['nova_password'],
|
||||
db_ncc_rel['db_host'],
|
||||
'nova')
|
||||
|
||||
expected = {
|
||||
'DEFAULT': {
|
||||
'dhcpbridge_flagfile': '/etc/nova/nova.conf',
|
||||
'dhcpbridge': '/usr/bin/nova-dhcpbridge',
|
||||
'logdir': '/var/log/nova',
|
||||
'state_path': '/var/lib/nova',
|
||||
'force_dhcp_release': 'True',
|
||||
'iscsi_helper': 'tgtadm',
|
||||
'libvirt_use_virtio_for_bridges': 'True',
|
||||
'connection_type': 'libvirt',
|
||||
'root_helper': 'sudo nova-rootwrap /etc/nova/rootwrap.conf',
|
||||
'verbose': 'False',
|
||||
'debug': 'False',
|
||||
'api_paste_config': '/etc/nova/api-paste.ini',
|
||||
'volumes_path': '/var/lib/nova/volumes',
|
||||
'auth_strategy': 'keystone',
|
||||
'compute_driver': 'libvirt.LibvirtDriver',
|
||||
'network_manager': 'nova.network.manager.FlatDHCPManager',
|
||||
's3_listen_port': '3323',
|
||||
'osapi_compute_listen_port': '8764',
|
||||
}
|
||||
}
|
||||
|
||||
if self._get_openstack_release() < self.trusty_kilo:
|
||||
# Juno and earlier
|
||||
expected['database'] = {
|
||||
'connection': db_uri
|
||||
}
|
||||
expected['DEFAULT'].update({
|
||||
'lock_path': '/var/lock/nova',
|
||||
'libvirt_use_virtio_for_bridges': 'True',
|
||||
'compute_driver': 'libvirt.LibvirtDriver',
|
||||
'rabbit_userid': 'nova',
|
||||
'rabbit_virtual_host': 'openstack',
|
||||
'rabbit_password': rmq_ncc_rel['password'],
|
||||
'rabbit_host': rmq_ncc_rel['hostname'],
|
||||
'glance_api_servers': gl_ncc_rel['glance-api-server']
|
||||
})
|
||||
else:
|
||||
# Kilo and later
|
||||
expected['database'] = {
|
||||
'connection': db_uri,
|
||||
'max_pool_size': u.not_null,
|
||||
}
|
||||
expected['glance'] = {
|
||||
'api_servers': gl_ncc_rel['glance-api-server'],
|
||||
}
|
||||
expected['osapi_v3'] = {
|
||||
'enabled': 'True',
|
||||
}
|
||||
# due to worker multiplier changes and the way the unit changes
|
||||
# depending on whether it is LXC or KVM, we can't actually guess
|
||||
# the workers reliable.
|
||||
expected['conductor'] = {
|
||||
'workers': u.not_null,
|
||||
}
|
||||
expected['oslo_messaging_rabbit'] = {
|
||||
'rabbit_userid': 'nova',
|
||||
'rabbit_virtual_host': 'openstack',
|
||||
'rabbit_password': rmq_ncc_rel['password'],
|
||||
'rabbit_host': rmq_ncc_rel['hostname'],
|
||||
}
|
||||
expected['oslo_concurrency'] = {
|
||||
'lock_path': '/var/lock/nova',
|
||||
}
|
||||
|
||||
if self._get_openstack_release() < self.trusty_mitaka:
|
||||
expected['DEFAULT'].update({
|
||||
'ec2_private_dns_show_ip': 'True',
|
||||
'enabled_apis': 'ec2,osapi_compute,metadata',
|
||||
'keystone_ec2_url': ks_ec2,
|
||||
'ec2_listen_port': '8763'
|
||||
})
|
||||
elif self._get_openstack_release() >= self.trusty_mitaka:
|
||||
expected['DEFAULT'].update({
|
||||
'enabled_apis': 'osapi_compute,metadata',
|
||||
})
|
||||
|
||||
if self._get_openstack_release() >= self.xenial_ocata:
|
||||
del expected['DEFAULT']['force_dhcp_release']
|
||||
del expected['DEFAULT']['network_manager']
|
||||
del expected['oslo_messaging_rabbit']
|
||||
expected['DEFAULT']['transport_url'] = u.not_null
|
||||
del expected['DEFAULT']['auth_strategy']
|
||||
expected['api'] = {'auth_strategy': 'keystone'}
|
||||
del expected['DEFAULT']['api_paste_config']
|
||||
expected['wsgi'] = {'api_paste_config': '/etc/nova/api-paste.ini'}
|
||||
|
||||
for section, pairs in expected.iteritems():
|
||||
ret = u.validate_config_data(unit, conf, section, pairs)
|
||||
if ret:
|
||||
message = "nova config error: {}".format(ret)
|
||||
amulet.raise_status(amulet.FAIL, msg=message)
|
||||
|
||||
def test_302_api_rate_limiting_is_enabled(self):
|
||||
"""
|
||||
Check that API rate limiting is enabled.
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -65,7 +65,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
|
||||
|
|
|
@ -424,15 +424,27 @@ class NovaCCUtilsTests(CharmTestCase):
|
|||
self.assertEqual(sorted(ex), sorted(pkgs))
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_determine_packages_base_ocata(self, subcontext):
|
||||
def test_determine_packages_base_queens(self, subcontext):
|
||||
self.relation_ids.return_value = []
|
||||
self.os_release.return_value = 'ocata'
|
||||
self.os_release.return_value = 'queens'
|
||||
self.token_cache_pkgs.return_value = []
|
||||
self.enable_memcache.return_value = False
|
||||
pkgs = utils.determine_packages()
|
||||
ex = list(set(utils.BASE_PACKAGES + utils.BASE_SERVICES))
|
||||
self.assertEqual(sorted(ex), sorted(pkgs))
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_determine_packages_base_rocky(self, subcontext):
|
||||
self.relation_ids.return_value = []
|
||||
self.os_release.return_value = 'rocky'
|
||||
self.token_cache_pkgs.return_value = []
|
||||
self.enable_memcache.return_value = False
|
||||
pkgs = utils.determine_packages()
|
||||
ex = list(set([p for p in utils.BASE_PACKAGES + utils.BASE_SERVICES
|
||||
if not p.startswith('python-')] + utils.PY3_PACKAGES))
|
||||
ex.remove('libapache2-mod-wsgi')
|
||||
self.assertEqual(sorted(ex), sorted(pkgs))
|
||||
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_determine_packages_serial_console(self,
|
||||
subcontext):
|
||||
|
@ -455,6 +467,20 @@ class NovaCCUtilsTests(CharmTestCase):
|
|||
for console_pkg in console_pkgs:
|
||||
self.assertNotIn(console_pkg, pkgs)
|
||||
|
||||
def test_determine_purge_packages(self):
|
||||
'Ensure no packages are identified for purge prior to rocky'
|
||||
self.os_release.return_value = 'queens'
|
||||
self.assertEqual(utils.determine_purge_packages(), [])
|
||||
|
||||
def test_determine_purge_packages_rocky(self):
|
||||
'Ensure python packages are identified for purge at rocky'
|
||||
self.os_release.return_value = 'rocky'
|
||||
self.assertEqual(utils.determine_purge_packages(),
|
||||
[p for p in utils.BASE_PACKAGES
|
||||
if p.startswith('python-')] +
|
||||
['python-nova', 'python-memcache',
|
||||
'libapache2-mod-wsgi'])
|
||||
|
||||
@patch.object(utils, 'restart_map')
|
||||
def test_determine_ports(self, restart_map):
|
||||
restart_map.return_value = {
|
||||
|
|
Loading…
Reference in New Issue