diff --git a/hooks/neutron_api_utils.py b/hooks/neutron_api_utils.py index d87b16ea..59ce822b 100755 --- a/hooks/neutron_api_utils.py +++ b/hooks/neutron_api_utils.py @@ -124,6 +124,10 @@ PURGE_PACKAGES = [ 'python-psycopg2', ] +PURGE_EXTRA_PACKAGES_ON_TRAIN = [ + 'python3-neutron-lbaas', +] + VERSION_PACKAGE = 'neutron-common' BASE_SERVICES = [ @@ -427,7 +431,9 @@ def determine_packages(source=None): def determine_purge_packages(): '''Return a list of packages to purge for the current OS release''' cmp_os_source = CompareOpenStackReleases(os_release('neutron-common')) - if cmp_os_source >= 'rocky': + if cmp_os_source >= 'train': + return PURGE_PACKAGES + PURGE_EXTRA_PACKAGES_ON_TRAIN + elif cmp_os_source >= 'rocky': return PURGE_PACKAGES return [] @@ -467,6 +473,9 @@ def resource_map(release=None): if CompareOpenStackReleases(release) >= 'liberty': resource_map.update(LIBERTY_RESOURCE_MAP) + if CompareOpenStackReleases(release) >= 'train': + resource_map.pop(NEUTRON_LBAAS_CONF) + if os.path.exists('/etc/apache2/conf-available'): resource_map.pop(APACHE_CONF) else: diff --git a/templates/train/neutron.conf b/templates/train/neutron.conf new file mode 100644 index 00000000..330ac238 --- /dev/null +++ b/templates/train/neutron.conf @@ -0,0 +1,142 @@ +# train +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +# Restart trigger {{ restart_trigger }} +############################################################################### +[DEFAULT] +verbose = {{ verbose }} +debug = {{ debug }} +use_syslog = {{ use_syslog }} +state_path = /var/lib/neutron +bind_host = {{ bind_host }} +auth_strategy = keystone +api_workers = {{ workers }} +rpc_workers = {{ workers }} + +{% if transport_url %} +transport_url = {{ transport_url }} +{% endif %} + +router_distributed = {{ enable_dvr }} + +{% if dns_domain -%} +dns_domain = {{ dns_domain }} +{% endif -%} + +l3_ha = {{ l3_ha }} +{% if l3_ha -%} +max_l3_agents_per_router = {{ max_l3_agents_per_router }} +{% endif -%} + +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} + +{% if neutron_bind_port -%} +bind_port = {{ neutron_bind_port }} +{% else -%} +bind_port = 9696 +{% endif -%} + +{% if core_plugin -%} +core_plugin = {{ core_plugin }} +{% if service_plugins -%} +service_plugins = {{ service_plugins }} +{% endif -%} +{% endif -%} + +{% if neutron_security_groups -%} +allow_overlapping_ips = True +{% endif -%} + +dhcp_agents_per_network = {{ dhcp_agents_per_network }} + +notify_nova_on_port_status_changes = True +notify_nova_on_port_data_changes = True + +{% if sections and 'DEFAULT' in sections -%} +{% for key, value in sections['DEFAULT'] -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif %} + +{% if user_config_flags -%} +{% for key, value in user_config_flags.items() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} + +{% if global_physnet_mtu -%} +global_physnet_mtu = {{ global_physnet_mtu }} +{% endif -%} + +{% if enable_designate -%} +external_dns_driver = designate +{% endif -%} + +{% include "section-zeromq" %} + +[quotas] +{% if quota_driver -%} +quota_driver = {{ quota_driver }} +{% else -%} +quota_driver = neutron.db.quota.driver.DbQuotaDriver +{% endif -%} +{% if neutron_security_groups -%} +quota_items = network,subnet,port,security_group,security_group_rule +quota_security_group = {{ quota_security_group }} +quota_security_group_rule = {{ quota_security_group_rule }} +{% else -%} +quota_items = network,subnet,port +{% endif -%} +quota_network = {{ quota_network }} +quota_subnet = {{ quota_subnet }} +quota_port = {{ quota_port }} +quota_vip = {{ quota_vip }} +quota_pool = {{ quota_pool }} +quota_member = {{ quota_member }} +quota_health_monitors = {{ quota_health_monitors }} +quota_router = {{ quota_router }} +quota_floatingip = {{ quota_floatingip }} + +[agent] +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf + +{% include "section-keystone-authtoken-mitaka" %} + +{% include "parts/section-database" %} + +{% include "section-oslo-messaging-rabbit" %} + +{% include "section-oslo-notifications" %} + +[oslo_concurrency] +lock_path = $state_path/lock + +{% include "parts/section-nova" %} + +{% if enable_designate -%} +{% include "parts/section-designate" %} +{% endif -%} + +{% include "parts/section-placement" %} + +{% if firewall_v2 -%} +[service_providers] +service_provider = FIREWALL_V2:fwaas_db:neutron_fwaas.services.firewall.service_drivers.agents.agents.FirewallAgentDriver:default +{% endif %} + +{% include "section-oslo-middleware" %} + +{% for section in sections -%} +{% if section != 'DEFAULT' -%} +[{{ section }}] +{% for key, value in sections[section] -%} +{{ key }} = {{ value }} +{% endfor %} +{% endif %} +{%- endfor %} diff --git a/unit_tests/test_neutron_api_utils.py b/unit_tests/test_neutron_api_utils.py index 319245ae..09ebe83d 100644 --- a/unit_tests/test_neutron_api_utils.py +++ b/unit_tests/test_neutron_api_utils.py @@ -422,6 +422,33 @@ class TestNeutronAPIUtils(CharmTestCase): fwaas_migrate_v1_to_v2.assert_called_once_with() configs.write_all.assert_called_once_with() + @patch.object(nutils, 'fwaas_migrate_v1_to_v2') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_install_source') + @patch.object(nutils, 'migrate_neutron_database') + @patch.object(nutils, 'stamp_neutron_database') + def test_do_openstack_upgrade_train(self, + stamp_neutron_db, + migrate_neutron_db, + gsrc, + fwaas_migrate_v1_to_v2): + self.is_elected_leader.return_value = True + self.os_release.return_value = 'train' + self.config.side_effect = self.test_config.get + self.test_config.set('openstack-origin', 'cloud:bionic-train') + gsrc.return_value = 'train' + self.get_os_codename_install_source.return_value = 'train' + self.filter_missing_packages.return_value = ['python-neutron'] + configs = MagicMock() + nutils.do_openstack_upgrade(configs) + self.apt_purge.assert_called_with(['python-neutron'], fatal=True) + self.apt_autoremove.assert_called_with(purge=True, fatal=True) + self.filter_missing_packages.assert_called_with( + nutils.PURGE_PACKAGES + nutils.PURGE_EXTRA_PACKAGES_ON_TRAIN) + self.assertFalse(stamp_neutron_db.called) + fwaas_migrate_v1_to_v2.assert_called_once_with() + configs.write_all.assert_called_once_with() + @patch.object(charmhelpers.contrib.openstack.utils, 'get_os_codename_install_source') @patch.object(nutils, 'migrate_neutron_database')