]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Cisco plugin check for a valid nexus driver
authorArvind Somya <asomya@cisco.com>
Thu, 18 Jul 2013 20:03:22 +0000 (16:03 -0400)
committerArvind Somya <asomya@cisco.com>
Thu, 18 Jul 2013 21:07:27 +0000 (17:07 -0400)
The Cisco plugin model should check for a valid Nexus driver before performing any
operations on hardware nexus devices.

Change-Id: Ib7760cc7bb24e2c7f6692cbd8274aefa71dc21a1
Fixes: Bug #1202822
neutron/plugins/cisco/models/virt_phy_sw_v2.py

index 8d655806606c64cabd4dc36d379f27a92fb2299d..d51b550edc2b37a49a5b5a277e06d1c4b5b456b2 100644 (file)
@@ -92,6 +92,12 @@ class VirtualPhysicalSwitchModelV2(neutron_plugin_base_v2.NeutronPluginBaseV2):
                   {'module': __name__,
                    'name': self.__class__.__name__})
 
+        # Check whether we have a valid Nexus driver loaded
+        self.config_nexus = False
+        nexus_driver = cfg.CONF.CISCO.nexus_driver
+        if nexus_driver.endswith('CiscoNEXUSDriver'):
+            self.config_nexus = True
+
     def __getattribute__(self, name):
         """Delegate calls to OVS sub-plugin.
 
@@ -252,6 +258,9 @@ class VirtualPhysicalSwitchModelV2(neutron_plugin_base_v2.NeutronPluginBaseV2):
 
     def _invoke_nexus_for_net_create(self, context, tenant_id, net_id,
                                      instance_id):
+        if not self.config_nexus:
+            return False
+
         net_dict = self.get_network(context, net_id)
         net_name = net_dict['name']
 
@@ -367,11 +376,12 @@ class VirtualPhysicalSwitchModelV2(neutron_plugin_base_v2.NeutronPluginBaseV2):
         """
         LOG.debug(_("delete_port() called"))
         port = self.get_port(context, id)
-        vlan_id = self._get_segmentation_id(port['network_id'])
-        n_args = [port['device_id'], vlan_id]
-        self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
-                                       self._func_name(),
-                                       n_args)
+        if self.config_nexus:
+            vlan_id = self._get_segmentation_id(port['network_id'])
+            n_args = [port['device_id'], vlan_id]
+            self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
+                                           self._func_name(),
+                                           n_args)
         try:
             args = [context, id]
             ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN,