From bf0cdcf9ee8898d53c4b0d8a347aa31a931feba2 Mon Sep 17 00:00:00 2001 From: Anton Kremenetsky Date: Wed, 7 Feb 2018 20:27:07 +0300 Subject: [PATCH] load interface_driver using a symbolic name Instead of relying on a full class path let's use symbolic names and namespaces from setup.cfg which relies on stevedore to use a proper class. This can only be used for code-paths that do not rely on direct usage of importlib which is not the case for the metering agent, which is why its config is left untouched. Co-Authored-By: Anton Kremenetsky Co-Authored-By: Dmitrii Shcherbakov Change-Id: I4d3389a0fe376fed87265f51fdd69caf14fb3b16 Closes-Bug: #1747964 --- templates/mitaka/dhcp_agent.ini | 2 +- templates/mitaka/l3_agent.ini | 28 ++++++++++++++++++++ templates/mitaka/lbaas_agent.ini | 13 ++++++++++ templates/newton/l3_agent.ini | 2 +- templates/newton/lbaas_agent.ini | 2 +- tests/basic_deployment.py | 44 ++++++++++++++++++++++++++------ 6 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 templates/mitaka/l3_agent.ini create mode 100644 templates/mitaka/lbaas_agent.ini diff --git a/templates/mitaka/dhcp_agent.ini b/templates/mitaka/dhcp_agent.ini index b4649430..b70d74c5 100644 --- a/templates/mitaka/dhcp_agent.ini +++ b/templates/mitaka/dhcp_agent.ini @@ -4,7 +4,7 @@ ############################################################################### [DEFAULT] state_path = /var/lib/neutron -interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +interface_driver = openvswitch dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf debug = {{ debug }} diff --git a/templates/mitaka/l3_agent.ini b/templates/mitaka/l3_agent.ini new file mode 100644 index 00000000..6c954e8d --- /dev/null +++ b/templates/mitaka/l3_agent.ini @@ -0,0 +1,28 @@ +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +############################################################################### +[DEFAULT] +interface_driver = openvswitch +auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0 +auth_region = {{ region }} +admin_tenant_name = {{ service_tenant }} +admin_user = {{ service_username }} +admin_password = {{ service_password }} +root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf +handle_internal_only_routers = {{ handle_internal_only_router }} +{% if plugin == 'n1kv' %} +l3_agent_manager = neutron.agent.l3_agent.L3NATAgentWithStateReport +external_network_bridge = br-int +ovs_use_veth = False +use_namespaces = True +{% else %} +ovs_use_veth = True +{% endif %} +{% if external_configuration_new -%} +gateway_external_network_id = +external_network_bridge = +{% elif ext_net_id %} +gateway_external_network_id = {{ ext_net_id }} +{% endif -%} +agent_mode = {{ agent_mode }} diff --git a/templates/mitaka/lbaas_agent.ini b/templates/mitaka/lbaas_agent.ini new file mode 100644 index 00000000..7fc92ffb --- /dev/null +++ b/templates/mitaka/lbaas_agent.ini @@ -0,0 +1,13 @@ +# kilo +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +############################################################################### +[DEFAULT] +periodic_interval = 10 +interface_driver = openvswitch +ovs_use_veth = False +device_driver = neutron_lbaas.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver +[haproxy] +loadbalancer_state_path = $state_path/lbaas +user_group = nogroup diff --git a/templates/newton/l3_agent.ini b/templates/newton/l3_agent.ini index d324f33e..5aecdc58 100644 --- a/templates/newton/l3_agent.ini +++ b/templates/newton/l3_agent.ini @@ -4,7 +4,7 @@ # Configuration file maintained by Juju. Local changes may be overwritten. ############################################################################### [DEFAULT] -interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +interface_driver = openvswitch auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0 auth_region = {{ region }} admin_tenant_name = {{ service_tenant }} diff --git a/templates/newton/lbaas_agent.ini b/templates/newton/lbaas_agent.ini index 3ece1974..73156230 100644 --- a/templates/newton/lbaas_agent.ini +++ b/templates/newton/lbaas_agent.ini @@ -4,7 +4,7 @@ # Configuration file maintained by Juju. Local changes may be overwritten. ############################################################################### [DEFAULT] -interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver +interface_driver = openvswitch device_driver = neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver [haproxy] loadbalancer_state_path = $state_path/lbaas diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 884e2400..56696776 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -15,6 +15,9 @@ from charmhelpers.contrib.openstack.amulet.utils import ( # ERROR ) +from charmhelpers.contrib.openstack.utils import ( + CompareOpenStackReleases, +) # Use DEBUG to turn on debug logging u = OpenStackAmuletUtils(DEBUG) @@ -597,10 +600,18 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment): u.log.debug('Checking neutron gateway dhcp agent config file data...') unit = self.neutron_gateway_sentry conf = '/etc/neutron/dhcp_agent.ini' + + cmp_os_release = CompareOpenStackReleases( + self._get_openstack_release_string() + ) + if cmp_os_release >= 'mitaka': + interface_driver = 'openvswitch' + else: + interface_driver = ('neutron.agent.linux.interface.' + 'OVSInterfaceDriver') expected = { 'state_path': '/var/lib/neutron', - 'interface_driver': 'neutron.agent.linux.interface.' - 'OVSInterfaceDriver', + 'interface_driver': interface_driver, 'dhcp_driver': 'neutron.agent.linux.dhcp.Dnsmasq', 'root_helper': 'sudo /usr/bin/neutron-rootwrap ' '/etc/neutron/rootwrap.conf', @@ -653,9 +664,17 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment): interface='publicURL') conf = '/etc/neutron/l3_agent.ini' + + cmp_os_release = CompareOpenStackReleases( + self._get_openstack_release_string() + ) + if cmp_os_release >= 'mitaka': + interface_driver = 'openvswitch' + else: + interface_driver = ('neutron.agent.linux.interface.' + 'OVSInterfaceDriver') expected = { - 'interface_driver': 'neutron.agent.linux.interface.' - 'OVSInterfaceDriver', + 'interface_driver': interface_driver, 'auth_url': ep, 'auth_region': 'RegionOne', 'admin_tenant_name': 'services', @@ -679,10 +698,17 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment): unit = self.neutron_gateway_sentry conf = '/etc/neutron/lbaas_agent.ini' + cmp_os_release = CompareOpenStackReleases( + self._get_openstack_release_string() + ) + if cmp_os_release >= 'mitaka': + interface_driver = 'openvswitch' + else: + interface_driver = ('neutron.agent.linux.interface.' + 'OVSInterfaceDriver') expected = { 'DEFAULT': { - 'interface_driver': 'neutron.agent.linux.interface.' - 'OVSInterfaceDriver', + 'interface_driver': interface_driver, 'periodic_interval': '10', 'ovs_use_veth': 'False', }, @@ -753,13 +779,15 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment): 'config file data...') unit = self.neutron_gateway_sentry conf = '/etc/neutron/metering_agent.ini' + + interface_driver = ('neutron.agent.linux.interface.' + 'OVSInterfaceDriver') expected = { 'driver': 'neutron.services.metering.drivers.iptables.' 'iptables_driver.IptablesMeteringDriver', 'measure_interval': '30', 'report_interval': '300', - 'interface_driver': 'neutron.agent.linux.interface.' - 'OVSInterfaceDriver', + 'interface_driver': interface_driver, 'use_namespaces': 'True' } section = 'DEFAULT'