Merge "py3: Switch to Python 3 for OpenStack Rocky"

This commit is contained in:
Zuul 2018-10-04 16:21:28 +00:00 committed by Gerrit Code Review
commit d0f0dbf577
6 changed files with 50 additions and 6 deletions

View File

@ -53,6 +53,7 @@ from neutron_ovs_utils import (
install_tmpfilesd, install_tmpfilesd,
pause_unit_helper, pause_unit_helper,
resume_unit_helper, resume_unit_helper,
determine_purge_packages,
) )
hooks = Hooks() hooks = Hooks()
@ -102,6 +103,10 @@ def config_changed():
install_packages() install_packages()
install_tmpfilesd() install_tmpfilesd()
# NOTE(jamespage): purge any packages as a result of py3 switch
# at rocky.
purge_packages(determine_purge_packages())
configure_ovs() configure_ovs()
CONFIGS.write_all() CONFIGS.write_all()
# NOTE(fnordahl): configure_sriov must be run after CONFIGS.write_all() # NOTE(fnordahl): configure_sriov must be run after CONFIGS.write_all()

View File

@ -76,6 +76,8 @@ from charmhelpers.fetch import (
apt_purge, apt_purge,
apt_update, apt_update,
filter_installed_packages, filter_installed_packages,
filter_missing_packages,
apt_autoremove,
get_upstream_version get_upstream_version
) )
@ -107,6 +109,15 @@ NEUTRON_METADATA_AGENT_CONF = "/etc/neutron/metadata_agent.ini"
DVR_PACKAGES = ['neutron-l3-agent'] DVR_PACKAGES = ['neutron-l3-agent']
DHCP_PACKAGES = ['neutron-dhcp-agent'] DHCP_PACKAGES = ['neutron-dhcp-agent']
METADATA_PACKAGES = ['neutron-metadata-agent'] METADATA_PACKAGES = ['neutron-metadata-agent']
PY3_PACKAGES = [
'python3-neutron',
]
PURGE_PACKAGES = [
'python-neutron',
]
PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf' PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf'
TEMPLATES = 'templates/' TEMPLATES = 'templates/'
OVS_DEFAULT = '/etc/default/openvswitch-switch' OVS_DEFAULT = '/etc/default/openvswitch-switch'
@ -221,7 +232,6 @@ DATA_BRIDGE = 'br-data'
def install_packages(): def install_packages():
status_set('maintenance', 'Installing apt packages')
apt_update() apt_update()
# NOTE(jamespage): install neutron-common package so we always # NOTE(jamespage): install neutron-common package so we always
# get a clear signal on which OS release is # get a clear signal on which OS release is
@ -234,21 +244,26 @@ def install_packages():
dkms_packages = determine_dkms_package() dkms_packages = determine_dkms_package()
if dkms_packages: if dkms_packages:
apt_install([headers_package()] + dkms_packages, fatal=True) apt_install([headers_package()] + dkms_packages, fatal=True)
apt_install(filter_installed_packages(determine_packages()), missing_packages = filter_installed_packages(determine_packages())
fatal=True) if missing_packages:
status_set('maintenance', 'Installing packages')
apt_install(missing_packages,
fatal=True)
if use_dpdk(): if use_dpdk():
enable_ovs_dpdk() enable_ovs_dpdk()
def purge_packages(pkg_list): def purge_packages(pkg_list):
status_set('maintenance', 'Purging unused apt packages')
purge_pkgs = [] purge_pkgs = []
required_packages = determine_packages() required_packages = determine_packages()
for pkg in pkg_list: for pkg in pkg_list:
if pkg not in required_packages: if pkg not in required_packages:
purge_pkgs.append(pkg) purge_pkgs.append(pkg)
purge_pkgs = filter_missing_packages(purge_pkgs)
if purge_pkgs: if purge_pkgs:
status_set('maintenance', 'Purging unused packages')
apt_purge(purge_pkgs, fatal=True) apt_purge(purge_pkgs, fatal=True)
apt_autoremove(purge=True, fatal=True)
def determine_packages(): def determine_packages():
@ -278,9 +293,22 @@ def determine_packages():
else: else:
pkgs.append('neutron-plugin-sriov-agent') pkgs.append('neutron-plugin-sriov-agent')
if cmp_release >= 'rocky':
pkgs = [p for p in pkgs if not p.startswith('python-')]
pkgs.extend(PY3_PACKAGES)
return pkgs return pkgs
def determine_purge_packages():
cmp_release = CompareOpenStackReleases(
os_release('neutron-common', base='icehouse',
reset_cache=True))
if cmp_release >= 'rocky':
return PURGE_PACKAGES
return []
def register_configs(release=None): def register_configs(release=None):
release = release or os_release('neutron-common', base='icehouse') release = release or os_release('neutron-common', base='icehouse')
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,

View File

@ -364,7 +364,7 @@ class NeutronOVSBasicDeployment(OpenStackAmuletDeployment):
set_default = {'enable-qos': 'False'} set_default = {'enable-qos': 'False'}
set_alternate = {'enable-qos': 'True'} set_alternate = {'enable-qos': 'True'}
self.d.configure('neutron-api', set_alternate) self.d.configure('neutron-api', set_alternate)
self._wait_and_check() self._wait_and_check(sleep=60)
qos_plugin = 'qos' qos_plugin = 'qos'
config = u._get_config( config = u._get_config(
self.neutron_api_sentry, '/etc/neutron/neutron.conf') self.neutron_api_sentry, '/etc/neutron/neutron.conf')

View File

@ -66,7 +66,7 @@ basepython = python2.7
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = 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] [testenv:func27-dfs]
# Charm Functional Test # Charm Functional Test

View File

@ -46,6 +46,8 @@ TO_PATCH = [
'enable_nova_metadata', 'enable_nova_metadata',
'enable_local_dhcp', 'enable_local_dhcp',
'install_tmpfilesd', 'install_tmpfilesd',
'purge_packages',
'determine_purge_packages',
] ]
NEUTRON_CONF_DIR = "/etc/neutron" NEUTRON_CONF_DIR = "/etc/neutron"
@ -107,6 +109,14 @@ class NeutronOVSHooksTests(CharmTestCase):
self.assertTrue(self.CONFIGS.write_all.called) self.assertTrue(self.CONFIGS.write_all.called)
self.configure_ovs.assert_called_with() self.configure_ovs.assert_called_with()
def test_config_changed_rocky_upgrade(self):
self.determine_purge_packages.return_value = ['python-neutron']
self._call_hook('config-changed')
self.install_packages.assert_called_with()
self.assertTrue(self.CONFIGS.write_all.called)
self.configure_ovs.assert_called_with()
self.purge_packages.assert_called_with(['python-neutron'])
@patch.object(hooks, 'neutron_plugin_joined') @patch.object(hooks, 'neutron_plugin_joined')
def test_neutron_plugin_api(self, _plugin_joined): def test_neutron_plugin_api(self, _plugin_joined):
self.relation_ids.return_value = ['rid'] self.relation_ids.return_value = ['rid']

View File

@ -43,6 +43,7 @@ TO_PATCH = [
'config', 'config',
'os_release', 'os_release',
'filter_installed_packages', 'filter_installed_packages',
'filter_missing_packages',
'lsb_release', 'lsb_release',
'neutron_plugin_attribute', 'neutron_plugin_attribute',
'full_restart', 'full_restart',