]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add bulking support for Cisco plugin
authorPaul Michali <pcm@cisco.com>
Mon, 18 Feb 2013 13:57:14 +0000 (08:57 -0500)
committerPaul Michali <pcm@cisco.com>
Mon, 18 Mar 2013 19:10:22 +0000 (12:10 -0700)
For each bulk request, the Cisco plugin will handle the call,
and, through the base class method, convert them into a series of
non-bulking calls wrapped in a transaction (emulated bulking).

Those non-bulking requests will all be forwarded to the Cisco
model (VirtualPhysicalSwitchModelV2), which will either handle
the request locally (as in create_port), or delegate the request
to the OVS plugin (OVSQuantumPluginV2).

As a result, the model should not receive any bulking calls.
However, the model was set up to delegate any bulk calls to the
OVS plugin (which would act like the existing code, in case we
decide later to pass along any bulk calls). An alternative would
be to raise an exception, if a bulk call was made to the model.

Prior to this change, all bulking calls were forwarded from the
Cisco plugin to the model plugin, which would would delegate
(directly or indirectly) to the OVS plugin. The OVS plugin would
turn the request into a transction of non-bulking calls.

The effective difference proposed is that the create_port will now
create the port in OVS and then create the network in the Nexus
plugin.

The Nexus plugin does not currently handle bulking so this commit
is implementing emulated (versus native) bulking.

This patch has been updated with latest from upstream (Havana).

blueprint bulk-api-cisco-plugin
Change-Id: I874295b32ea20c2ca393228b0893a9dd6c77baf2

quantum/plugins/cisco/models/virt_phy_sw_v2.py
quantum/plugins/cisco/network_plugin.py

index 0387b261a89341663f167088a7bfb3007eb410ad..876db0529ed8c0edb9bfbbf913d36d7f4acace49 100644 (file)
@@ -51,7 +51,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
     supported_extension_aliases = []
     _plugins = {}
     _inventory = {}
-    _methods_to_delegate = ['get_network', 'get_networks',
+    _methods_to_delegate = ['create_network_bulk',
+                            'get_network', 'get_networks',
                             'create_port_bulk',
                             'get_port', 'get_ports',
                             'create_subnet', 'create_subnet_bulk',
@@ -90,20 +91,23 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
     def __getattribute__(self, name):
         """
         This delegates the calls to the methods implemented only by the OVS
-        sub-plugin.
+        sub-plugin. Note: Currently, bulking is handled by the caller
+        (PluginV2), and this model class expects to receive only non-bulking
+        calls. If, however, a bulking call is made, this will method will
+        delegate the call to the OVS plugin.
         """
-        super_getattr = super(VirtualPhysicalSwitchModelV2,
-                              self).__getattribute__
-        methods = super_getattr('_methods_to_delegate')
+        super_getattribute = super(VirtualPhysicalSwitchModelV2,
+                                   self).__getattribute__
+        methods = super_getattribute('_methods_to_delegate')
 
         if name in methods:
-            plugin = super_getattr('_plugins')[const.VSWITCH_PLUGIN]
+            plugin = super_getattribute('_plugins')[const.VSWITCH_PLUGIN]
             return getattr(plugin, name)
 
         try:
-            return super_getattr(name)
+            return super_getattribute(name)
         except AttributeError:
-            plugin = super_getattr('_plugins')[const.VSWITCH_PLUGIN]
+            plugin = super_getattribute('_plugins')[const.VSWITCH_PLUGIN]
             return getattr(plugin, name)
 
     def _func_name(self, offset=0):
@@ -232,24 +236,6 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             # TODO (Sumit): Check if we need to perform any rollback here
             raise
 
-    def create_network_bulk(self, context, networks):
-        """
-        Perform this operation in the context of the configured device
-        plugins.
-        """
-        LOG.debug(_("create_network_bulk() called"))
-        try:
-            args = [context, networks]
-            ovs_output = self._plugins[
-                const.VSWITCH_PLUGIN].create_network_bulk(context, networks)
-            LOG.debug(_("ovs_output: %s"), ovs_output)
-            vlanids = self._get_all_segmentation_ids()
-            ovs_networks = ovs_output
-            return ovs_output
-        except:
-            # TODO (Sumit): Check if we need to perform any rollback here
-            raise
-
     def update_network(self, context, id, network):
         """
         Perform this operation in the context of the configured device
index 123b314d96e93ed950a42d6a70aa0988cbc13797..47044603610ee9d344f4b0f890a5a0ecc9c6306f 100644 (file)
@@ -39,12 +39,12 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
     Meta-Plugin with v2 API support for multiple sub-plugins.
     """
     supported_extension_aliases = ["Cisco Credential", "Cisco qos"]
-    _methods_to_delegate = ['create_network', 'create_network_bulk',
+    _methods_to_delegate = ['create_network',
                             'delete_network', 'update_network', 'get_network',
                             'get_networks',
-                            'create_port', 'create_port_bulk', 'delete_port',
+                            'create_port', 'delete_port',
                             'update_port', 'get_port', 'get_ports',
-                            'create_subnet', 'create_subnet_bulk',
+                            'create_subnet',
                             'delete_subnet', 'update_subnet',
                             'get_subnet', 'get_subnets', ]
     _master = True
@@ -73,6 +73,8 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         """
         When the configured model class offers to manage the state of the
         logical resources, we delegate the core API calls directly to it.
+        Note: Bulking calls will be handled by this class, and turned into
+        non-bulking calls to be considered for delegation.
         """
         master = object.__getattribute__(self, "_master")
         methods = object.__getattribute__(self, "_methods_to_delegate")