]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove ovs dependency in embrane plugin
authorIgnacio Scopetta <ignacio@embrane.com>
Sun, 20 Jul 2014 06:37:22 +0000 (23:37 -0700)
committerMarco Chirico <marco.chirico@embrane.com>
Fri, 29 Aug 2014 04:19:51 +0000 (21:19 -0700)
This patch changes the dependency of the embrane plugin from ovs to ml2.
Existing users of the old entry point will be upgraded on a case-by-case
base as needed, therefore no generic upgrade procedure is required.

Change-Id: Id192fc32bd6ba7a8926eff1190070b8df5327129
Closes-Bug: #1343024

neutron/plugins/embrane/l2base/ml2/__init__.py [new file with mode: 0644]
neutron/plugins/embrane/l2base/ml2/ml2_support.py [moved from neutron/plugins/embrane/l2base/openvswitch/openvswitch_support.py with 50% similarity]
neutron/plugins/embrane/l2base/openvswitch/__init__.py [deleted file]
neutron/plugins/embrane/plugins/embrane_ml2_plugin.py [moved from neutron/plugins/embrane/plugins/embrane_ovs_plugin.py with 51% similarity]
setup.cfg

diff --git a/neutron/plugins/embrane/l2base/ml2/__init__.py b/neutron/plugins/embrane/l2base/ml2/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 50%
rename from neutron/plugins/embrane/l2base/openvswitch/openvswitch_support.py
rename to neutron/plugins/embrane/l2base/ml2/ml2_support.py
index b5635a861d5b32de8b79f9c6330aada99a170af4..047973b09fe24cbcb413895408dafe688843f879 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2013 Embrane, Inc.
+# Copyright 2014 Embrane, Inc.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -14,6 +14,7 @@
 #    under the License.
 #
 # @author: Ivar Lazzaro, Embrane, Inc.
+# @author: Ignacio Scopetta, Embrane, Inc.
 
 from heleosapi import info as h_info
 
@@ -21,36 +22,34 @@ from neutron.common import constants
 from neutron import manager
 from neutron.plugins.embrane.l2base import support_base as base
 from neutron.plugins.embrane.l2base import support_exceptions as exc
-from neutron.plugins.openvswitch import ovs_db_v2
 
 
-class OpenvswitchSupport(base.SupportBase):
-    """OpenVSwitch plugin support.
+class Ml2Support(base.SupportBase):
+    """Modular Layer 2 plugin support.
 
-    Obtains the informations needed to build the user security zones
+    Obtains the information needed to build the user security zones.
 
     """
 
     def __init__(self):
-        super(OpenvswitchSupport, self).__init__()
+        super(Ml2Support, self).__init__()
 
     def retrieve_utif_info(self, context, neutron_port):
         plugin = manager.NeutronManager.get_plugin()
-        session = context.session
-        network_id = neutron_port["network_id"]
-        network_binding = ovs_db_v2.get_network_binding(session, network_id)
-        if not network_binding["segmentation_id"]:
-            raise exc.UtifInfoError(
-                err_msg=_("No segmentation_id found for the network, "
-                          "please be sure that tenant_network_type is vlan"))
-        network = plugin._get_network(context, network_id)
+        network = plugin.get_network(
+            context, neutron_port['network_id'])
         is_gw = (neutron_port["device_owner"] ==
                  constants.DEVICE_OWNER_ROUTER_GW)
-        result = h_info.UtifInfo(vlan=network_binding["segmentation_id"],
-                                 network_name=network["name"],
-                                 network_id=network["id"],
-                                 is_gw=is_gw,
-                                 owner_tenant=network["tenant_id"],
-                                 port_id=neutron_port["id"],
-                                 mac_address=neutron_port["mac_address"])
+        network_type = network.get('provider:network_type')
+        if network_type != 'vlan':
+            raise exc.UtifInfoError(
+                err_msg=_("Network type %s not supported. Please be sure "
+                          "that tenant_network_type is vlan") % network_type)
+        result = h_info.UtifInfo(network.get('provider:segmentation_id'),
+                                 network['name'],
+                                 network['id'],
+                                 is_gw,
+                                 network['tenant_id'],
+                                 neutron_port['id'],
+                                 neutron_port['mac_address'])
         return result
diff --git a/neutron/plugins/embrane/l2base/openvswitch/__init__.py b/neutron/plugins/embrane/l2base/openvswitch/__init__.py
deleted file mode 100644 (file)
index 25dc46b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2013 Embrane, Inc.
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-#
-# @author: Ivar Lazzaro, Embrane, Inc.
similarity index 51%
rename from neutron/plugins/embrane/plugins/embrane_ovs_plugin.py
rename to neutron/plugins/embrane/plugins/embrane_ml2_plugin.py
index 3318885e85b2bd8bb4898515740cb801d57eb361..954e5ea8a73c93d1748bc0de08e4bab978706592 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2013 Embrane, Inc.
+# Copyright 2014 Embrane, Inc.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    under the License.
 #
 # @author: Ivar Lazzaro, Embrane, Inc.
+# @author: Ignacio Scopetta, Embrane, Inc.
 
+from neutron.db import extraroute_db
+from neutron.db import l3_dvr_db
+from neutron.db import l3_gwmode_db
 from neutron.plugins.embrane import base_plugin as base
-from neutron.plugins.embrane.l2base.openvswitch import openvswitch_support
-from neutron.plugins.openvswitch import ovs_neutron_plugin as l2
+from neutron.plugins.embrane.l2base.ml2 import ml2_support
+from neutron.plugins.ml2 import plugin as l2
 
 
-class EmbraneOvsPlugin(base.EmbranePlugin, l2.OVSNeutronPluginV2):
-    '''EmbraneOvsPlugin.
+class EmbraneMl2Plugin(base.EmbranePlugin, l2.Ml2Plugin,
+                       l3_dvr_db.L3_NAT_with_dvr_db_mixin,
+                       l3_gwmode_db.L3_NAT_db_mixin,
+                       extraroute_db.ExtraRoute_db_mixin):
+    '''EmbraneMl2Plugin.
 
-    This plugin uses OpenVSwitch specific L2 plugin for providing L2 networks
+    This plugin uses Modular Layer 2 plugin for providing L2 networks
     and the base EmbranePlugin for L3.
 
     '''
-    _plugin_support = openvswitch_support.OpenvswitchSupport()
+    _plugin_support = ml2_support.Ml2Support()
 
     def __init__(self):
         '''First run plugin specific initialization, then Embrane's.'''
-        self._supported_extension_aliases.remove("l3_agent_scheduler")
-        l2.OVSNeutronPluginV2.__init__(self)
+        self._supported_extension_aliases.extend(["router", "extraroute",
+                                                  "ext-gw-mode"])
+        l2.Ml2Plugin.__init__(self)
         self._run_embrane_config()
index 94f7d9cd7bed1dee165c560acdb7e2ddd6785c3f..cf251094b925f7a12e5d520872e8d3c3566eddff 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -121,7 +121,7 @@ neutron.core_plugins =
     bigswitch = neutron.plugins.bigswitch.plugin:NeutronRestProxyV2
     brocade = neutron.plugins.brocade.NeutronPlugin:BrocadePluginV2
     cisco = neutron.plugins.cisco.network_plugin:PluginV2
-    embrane = neutron.plugins.embrane.plugins.embrane_ovs_plugin:EmbraneOvsPlugin
+    embrane = neutron.plugins.embrane.plugins.embrane_ml2_plugin:EmbraneMl2Plugin
     hyperv = neutron.plugins.hyperv.hyperv_neutron_plugin:HyperVNeutronPlugin
     ibm = neutron.plugins.ibm.sdnve_neutron_plugin:SdnvePluginV2
     linuxbridge = neutron.plugins.linuxbridge.lb_neutron_plugin:LinuxBridgePluginV2