]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Arista ML2 driver should ignore non-vlan networks
authorSukhdev Kapur <sukhdev@aristanetworks.com>
Wed, 8 Jul 2015 02:39:15 +0000 (19:39 -0700)
committerSukhdev Kapur <sukhdev@aristanetworks.com>
Fri, 10 Jul 2015 00:36:15 +0000 (17:36 -0700)
Arista ML2 Mech driver for VLANs presently does
not filter out non-vlan type networks (e.g vxlan).
This fix will simply ignore the request if a
non-vlan based network request is seen.

Change-Id: I99ec5c5772a9f1f63cf871a98be50bdd2ba5db62
Closes-Bug: 1472458

neutron/plugins/ml2/drivers/arista/mechanism_arista.py
neutron/tests/unit/plugins/ml2/drivers/arista/test_mechanism_arista.py

index 9d746bfb6570fe0e24774540e9bff396cda79b4d..4bcf0e7e82c9426574fd991af6d97792db3a8e77 100644 (file)
@@ -22,6 +22,7 @@ from oslo_log import log as logging
 
 from neutron.common import constants as n_const
 from neutron.i18n import _LI
+from neutron.plugins.common import constants as p_const
 from neutron.plugins.ml2.common import exceptions as ml2_exc
 from neutron.plugins.ml2 import driver_api
 from neutron.plugins.ml2.drivers.arista import config  # noqa
@@ -69,6 +70,9 @@ class AristaDriver(driver_api.MechanismDriver):
 
         network = context.current
         segments = context.network_segments
+        if segments[0][driver_api.NETWORK_TYPE] != p_const.TYPE_VLAN:
+            # If network type is not VLAN, do nothing
+            return
         network_id = network['id']
         tenant_id = network['tenant_id']
         if not tenant_id:
@@ -165,6 +169,10 @@ class AristaDriver(driver_api.MechanismDriver):
     def delete_network_postcommit(self, context):
         """Send network delete request to Arista HW."""
         network = context.current
+        segments = context.network_segments
+        if segments[0][driver_api.NETWORK_TYPE] != p_const.TYPE_VLAN:
+            # If networtk type is not VLAN, do nothing
+            return
         network_id = network['id']
         tenant_id = network['tenant_id']
         if not tenant_id:
@@ -202,6 +210,9 @@ class AristaDriver(driver_api.MechanismDriver):
             if not tenant_id:
                 tenant_id = context._plugin_context.tenant_id
             with self.eos_sync_lock:
+                if not db_lib.is_network_provisioned(tenant_id, network_id):
+                    # Ignore this request if network is not provisioned
+                    return
                 db_lib.remember_tenant(tenant_id)
                 db_lib.remember_vm(device_id, host, port_id,
                                network_id, tenant_id)
@@ -390,6 +401,9 @@ class AristaDriver(driver_api.MechanismDriver):
         device_owner = port['device_owner']
 
         try:
+            if not db_lib.is_network_provisioned(tenant_id, network_id):
+                # If we do not have network associated with this, ignore it
+                return
             hostname = self._host_name(host)
             if device_owner == n_const.DEVICE_OWNER_DHCP:
                 self.rpc.unplug_dhcp_port_from_network(device_id,
index 57d5071214879c2cb22ba3da81030bcbf9737d80..5fb19410575718463ab395c8ec9b650aa26120b9 100644 (file)
@@ -321,6 +321,7 @@ class AristaDriverTestCase(testlib_api.SqlTestCase):
                                         network_id, tenant_id),
             mock.call.is_network_provisioned(tenant_id, network_id,
                                              segmentation_id),
+            mock.call.is_network_provisioned(tenant_id, network_id),
             mock.call.unplug_host_from_network(device_id, orig_host_id,
                                                port_id, network_id, tenant_id),
             mock.call.num_nets_provisioned(tenant_id),
@@ -337,7 +338,8 @@ class AristaDriverTestCase(testlib_api.SqlTestCase):
                    'tenant_id': tenant_id,
                    'name': 'test-net',
                    'shared': shared}
-        network_segments = [{'segmentation_id': seg_id}]
+        network_segments = [{'segmentation_id': seg_id,
+                             'network_type': 'vlan'}]
         return FakeNetworkContext(network, network_segments, network)
 
     def _get_port_context(self, tenant_id, net_id, vm_id, network):