From: Cedric Brandily Date: Wed, 19 Aug 2015 00:02:17 +0000 (+0200) Subject: Move in-tree vendor VIF_TYPE_* constants X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=86476becd884a0f238354335bc87e5209d67c94f;p=openstack-build%2Fneutron-build.git Move in-tree vendor VIF_TYPE_* constants 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 --- diff --git a/neutron/db/migration/alembic_migrations/versions/2b801560a332_remove_hypervneutronplugin_tables.py b/neutron/db/migration/alembic_migrations/versions/2b801560a332_remove_hypervneutronplugin_tables.py index 6df244cdc..4e3f8bdc6 100644 --- a/neutron/db/migration/alembic_migrations/versions/2b801560a332_remove_hypervneutronplugin_tables.py +++ b/neutron/db/migration/alembic_migrations/versions/2b801560a332_remove_hypervneutronplugin_tables.py @@ -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: diff --git a/neutron/extensions/portbindings.py b/neutron/extensions/portbindings.py index 25cc4b0d2..1079a4e00 100644 --- a/neutron/extensions/portbindings.py +++ b/neutron/extensions/portbindings.py @@ -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 index 000000000..18697f231 --- /dev/null +++ b/neutron/plugins/ml2/drivers/hyperv/constants.py @@ -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' diff --git a/neutron/plugins/ml2/drivers/hyperv/mech_hyperv.py b/neutron/plugins/ml2/drivers/hyperv/mech_hyperv.py index 0fa888c6d..d11877226 100644 --- a/neutron/plugins/ml2/drivers/hyperv/mech_hyperv.py +++ b/neutron/plugins/ml2/drivers/hyperv/mech_hyperv.py @@ -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}) diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index dcb7e52d3..3f841bcee 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -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], diff --git a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py index 9484a61e8..90d1d2194 100644 --- a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py +++ b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py @@ -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]) diff --git a/neutron/plugins/opencontrail/contrail_plugin.py b/neutron/plugins/opencontrail/contrail_plugin.py index caf97a233..b83637d0a 100644 --- a/neutron/plugins/opencontrail/contrail_plugin.py +++ b/neutron/plugins/opencontrail/contrail_plugin.py @@ -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: diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py index 8b28eb087..15033b56e 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py @@ -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.' diff --git a/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py b/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py index 1237b8444..4f3b0320b 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py @@ -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 diff --git a/neutron/tests/unit/plugins/opencontrail/test_contrail_plugin.py b/neutron/tests/unit/plugins/opencontrail/test_contrail_plugin.py index b5ca8d18e..55b2abc27 100644 --- a/neutron/tests/unit/plugins/opencontrail/test_contrail_plugin.py +++ b/neutron/tests/unit/plugins/opencontrail/test_contrail_plugin.py @@ -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):