]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move in-tree vendor VIF_TYPE_* constants
authorCedric Brandily <zzelle@gmail.com>
Wed, 19 Aug 2015 00:02:17 +0000 (02:02 +0200)
committerCedric Brandily <zzelle@gmail.com>
Thu, 20 Aug 2015 22:12:29 +0000 (00:12 +0200)
VIF_TYPE_* constants[1] defines all vif types BUT vendor ones are only
used by in-tree/out-of-tree vendor code. This changes moves in-tree
VIF_TYPE_* constants[2] to vendor modules to ensure they will be removed
from neutron code on decomposition.

[1] in neutron.extensions.portbindings
[2] VIF_TYPE_HYPERV/IB_HOSTDEV/HW_WEB/VROUTER

Change-Id: Iee73426221d693689ba24d2ce2660bb7351f02fc
Partial-Bug: #1486279

neutron/db/migration/alembic_migrations/versions/2b801560a332_remove_hypervneutronplugin_tables.py
neutron/extensions/portbindings.py
neutron/plugins/ml2/drivers/hyperv/constants.py [new file with mode: 0644]
neutron/plugins/ml2/drivers/hyperv/mech_hyperv.py
neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py
neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py
neutron/plugins/opencontrail/contrail_plugin.py
neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py
neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py
neutron/tests/unit/plugins/opencontrail/test_contrail_plugin.py

index 6df244cdc0dfbfa8acffc0a0e099c40045e81d3a..4e3f8bdc6cf69cb755c30c7d7602a80c94e68d74 100644 (file)
@@ -36,8 +36,8 @@ from oslo_utils import uuidutils
 import sqlalchemy as sa
 from sqlalchemy.sql import expression as sa_expr
 
-from neutron.extensions import portbindings
 from neutron.plugins.common import constants as p_const
+from neutron.plugins.ml2.drivers.hyperv import constants
 
 FLAT_VLAN_ID = -1
 LOCAL_VLAN_ID = -2
@@ -114,7 +114,7 @@ def _migrate_port_bindings(engine):
         sa_expr.select(['*'], from_obj=port_binding_ports))
     ml2_bindings = [dict(x) for x in source_bindings]
     for binding in ml2_bindings:
-        binding['vif_type'] = portbindings.VIF_TYPE_HYPERV
+        binding['vif_type'] = constants.VIF_TYPE_HYPERV
         binding['driver'] = HYPERV
         segment = port_segment_map.get(binding['port_id'])
         if segment:
index 25cc4b0d2c90bdb5c6f6bd31bc2112ef74cc1aa2..1079a4e004382cfc40ac6471463d293e889f14d5 100644 (file)
@@ -75,11 +75,7 @@ VIF_TYPE_DVS = 'dvs'
 VIF_TYPE_BRIDGE = 'bridge'
 VIF_TYPE_802_QBG = '802.1qbg'
 VIF_TYPE_802_QBH = '802.1qbh'
-VIF_TYPE_HYPERV = 'hyperv'
 VIF_TYPE_MIDONET = 'midonet'
-VIF_TYPE_IB_HOSTDEV = 'ib_hostdev'
-VIF_TYPE_HW_VEB = 'hw_veb'
-VIF_TYPE_VROUTER = 'vrouter'
 VIF_TYPE_OTHER = 'other'
 
 VNIC_NORMAL = 'normal'
diff --git a/neutron/plugins/ml2/drivers/hyperv/constants.py b/neutron/plugins/ml2/drivers/hyperv/constants.py
new file mode 100644 (file)
index 0000000..18697f2
--- /dev/null
@@ -0,0 +1,16 @@
+# Copyright (c) 2015 Thales Services SAS
+# 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.
+
+VIF_TYPE_HYPERV = 'hyperv'
index 0fa888c6d185326698d1d7605dd9a9137a3135a3..d11877226d0088df88a850e0d09fd5e4ce837a3e 100644 (file)
@@ -17,6 +17,7 @@ from hyperv.neutron.ml2 import mech_hyperv
 
 from neutron.common import constants
 from neutron.extensions import portbindings
+from neutron.plugins.ml2.drivers.hyperv import constants as h_constants
 from neutron.plugins.ml2.drivers import mech_agent
 
 
@@ -33,5 +34,5 @@ class HypervMechanismDriver(mech_hyperv.HypervMechanismDriver,
     def __init__(self):
         super(HypervMechanismDriver, self).__init__(
             constants.AGENT_TYPE_HYPERV,
-            portbindings.VIF_TYPE_HYPERV,
+            h_constants.VIF_TYPE_HYPERV,
             {portbindings.CAP_PORT_FILTER: False})
index dcb7e52d38ff89615f719ff7d14db99e7cb2282d..3f841bcee60866e1b0e79ba16090d392145295af 100644 (file)
@@ -28,6 +28,7 @@ from neutron.services.qos import qos_consts
 
 
 LOG = log.getLogger(__name__)
+VIF_TYPE_HW_VEB = 'hw_veb'
 FLAT_VLAN = 0
 
 sriov_opts = [
@@ -66,7 +67,7 @@ class SriovNicSwitchMechanismDriver(api.MechanismDriver):
 
     def __init__(self,
                  agent_type=constants.AGENT_TYPE_NIC_SWITCH,
-                 vif_type=portbindings.VIF_TYPE_HW_VEB,
+                 vif_type=VIF_TYPE_HW_VEB,
                  vif_details={portbindings.CAP_PORT_FILTER: False},
                  supported_vnic_types=[portbindings.VNIC_DIRECT,
                                        portbindings.VNIC_MACVTAP],
index 9484a61e870ad0bc17d9645b7df19d0af5789c7e..90d1d21944e8b8a9d97cf4c1eb67d3faea5f404f 100644 (file)
@@ -23,6 +23,7 @@ from neutron.plugins.ml2 import driver_api as api
 from neutron.plugins.ml2.drivers import mech_agent
 
 LOG = log.getLogger(__name__)
+VIF_TYPE_IB_HOSTDEV = 'ib_hostdev'
 
 
 class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
@@ -38,7 +39,7 @@ class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
     def __init__(self):
         super(MlnxMechanismDriver, self).__init__(
             agent_type=n_const.AGENT_TYPE_MLNX,
-            vif_type=portbindings.VIF_TYPE_IB_HOSTDEV,
+            vif_type=VIF_TYPE_IB_HOSTDEV,
             vif_details={portbindings.CAP_PORT_FILTER: False},
             supported_vnic_types=[portbindings.VNIC_DIRECT])
 
index caf97a233baf80d1dba4349182d64e581199c5d9..b83637d0ae80b3d674507d450082374131a5825d 100644 (file)
@@ -40,6 +40,7 @@ opencontrail_opts = [
 
 cfg.CONF.register_opts(opencontrail_opts, 'CONTRAIL')
 
+VIF_TYPE_VROUTER = 'vrouter'
 CONTRAIL_EXCEPTION_MAP = {
     requests.codes.not_found: c_exc.ContrailNotFoundError,
     requests.codes.conflict: c_exc.ContrailConflictError,
@@ -72,7 +73,7 @@ class NeutronPluginContrailCoreV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
         """return VIF type and details."""
 
         binding = {
-            portbindings.VIF_TYPE: portbindings.VIF_TYPE_VROUTER,
+            portbindings.VIF_TYPE: VIF_TYPE_VROUTER,
             portbindings.VIF_DETAILS: {
                 # TODO(praneetb): Replace with new VIF security details
                 portbindings.CAP_PORT_FILTER:
index 8b28eb087edc46d5db3b8c8c975c4caf2c39407d..15033b56e904e594b8ca48dbd13bc59a3af21cab 100644 (file)
@@ -56,7 +56,7 @@ class TestFakePortContext(base.FakePortContext):
 
 
 class SriovNicSwitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_HW_VEB
+    VIF_TYPE = mech_driver.VIF_TYPE_HW_VEB
     CAP_PORT_FILTER = False
     AGENT_TYPE = constants.AGENT_TYPE_NIC_SWITCH
     VLAN_SEGMENTS = base.AgentMechanismVlanTestCase.VLAN_SEGMENTS
@@ -143,11 +143,11 @@ class SriovSwitchMechVnicTypeTestCase(SriovNicSwitchMechanismBaseTestCase):
 
     def test_vnic_type_direct(self):
         self._check_vif_type_for_vnic_type(portbindings.VNIC_DIRECT,
-                                           portbindings.VIF_TYPE_HW_VEB)
+                                           mech_driver.VIF_TYPE_HW_VEB)
 
     def test_vnic_type_macvtap(self):
         self._check_vif_type_for_vnic_type(portbindings.VNIC_MACVTAP,
-                                           portbindings.VIF_TYPE_HW_VEB)
+                                           mech_driver.VIF_TYPE_HW_VEB)
 
 
 class SriovSwitchMechProfileTestCase(SriovNicSwitchMechanismBaseTestCase):
@@ -162,7 +162,7 @@ class SriovSwitchMechProfileTestCase(SriovNicSwitchMechanismBaseTestCase):
 
     def test_profile_supported_pci_info(self):
         self._check_vif_for_pci_info(MELLANOX_CONNECTX3_PCI_INFO,
-                                     portbindings.VIF_TYPE_HW_VEB)
+                                     mech_driver.VIF_TYPE_HW_VEB)
 
     def test_profile_unsupported_pci_info(self):
         with mock.patch('neutron.plugins.ml2.drivers.mech_sriov.'
index 1237b8444bb11652b2146eaab6153705466608d0..4f3b0320beda87180e1d5116996880ca85f13c82 100644 (file)
@@ -33,7 +33,7 @@ with mock.patch.dict(sys.modules,
 
 
 class MlnxMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_IB_HOSTDEV
+    VIF_TYPE = mech_mlnx.VIF_TYPE_IB_HOSTDEV
     CAP_PORT_FILTER = False
     AGENT_TYPE = constants.AGENT_TYPE_MLNX
     VNIC_TYPE = portbindings.VNIC_DIRECT
index b5ca8d18e1daf7fad298a4e63e41d9981f93facc..55b2abc2710f5837c289776e296995fec0dc52da 100644 (file)
@@ -30,8 +30,8 @@ from neutron.db import db_base_plugin_v2
 from neutron.db import external_net_db
 from neutron.db import l3_db
 from neutron.db import securitygroups_db
-from neutron.extensions import portbindings
 from neutron.extensions import securitygroup as ext_sg
+from neutron.plugins.opencontrail import contrail_plugin
 from neutron.tests.unit import _test_extension_portbindings as test_bindings
 from neutron.tests.unit.api import test_extensions
 from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin
@@ -286,7 +286,7 @@ class TestContrailSecurityGroups(test_sg.TestSecurityGroups,
 
 class TestContrailPortBinding(ContrailPluginTestCase,
                               test_bindings.PortBindingsTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_VROUTER
+    VIF_TYPE = contrail_plugin.VIF_TYPE_VROUTER
     HAS_PORT_FILTER = True
 
     def setUp(self):