From 82a2d72cbea616482a49c3fff7eff3fe1e5f8a05 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Thu, 29 Oct 2015 23:30:17 +0900 Subject: [PATCH] Decompose ML2 mechanism driver for Mellanox This change removes Mellanox ML2 mechanism driver after its definition in networking-mlnx. DocImpact Closes-Bug: #1511234 Change-Id: Ie48ac22d8e7477c22ad1d48aa0c44153a01eb242 --- etc/neutron/plugins/mlnx/mlnx_conf.ini | 31 ------ .../eventlet/plugins/mlnx_neutron_agent.py | 19 ---- neutron/plugins/ml2/drivers/mlnx/README | 4 - neutron/plugins/ml2/drivers/mlnx/__init__.py | 0 .../ml2/drivers/mlnx/agent/__init__.py | 0 .../plugins/ml2/drivers/mlnx/agent/config.py | 50 --------- .../mlnx/agent/eswitch_neutron_agent.py | 60 ---------- neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py | 61 ----------- .../plugins/ml2/drivers/mlnx/requirements.txt | 1 - .../unit/plugins/ml2/drivers/mlnx/__init__.py | 0 .../ml2/drivers/mlnx/test_mech_mlnx.py | 103 ------------------ setup.cfg | 3 - 12 files changed, 332 deletions(-) delete mode 100644 etc/neutron/plugins/mlnx/mlnx_conf.ini delete mode 100644 neutron/cmd/eventlet/plugins/mlnx_neutron_agent.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/README delete mode 100644 neutron/plugins/ml2/drivers/mlnx/__init__.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/agent/__init__.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/agent/config.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/agent/eswitch_neutron_agent.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py delete mode 100644 neutron/plugins/ml2/drivers/mlnx/requirements.txt delete mode 100644 neutron/tests/unit/plugins/ml2/drivers/mlnx/__init__.py delete mode 100644 neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py diff --git a/etc/neutron/plugins/mlnx/mlnx_conf.ini b/etc/neutron/plugins/mlnx/mlnx_conf.ini deleted file mode 100644 index 1eb7c7c6d..000000000 --- a/etc/neutron/plugins/mlnx/mlnx_conf.ini +++ /dev/null @@ -1,31 +0,0 @@ -[eswitch] -# (ListOpt) Comma-separated list of -# : tuples mapping physical -# network names to the agent's node-specific physical network -# interfaces to be used for flat and VLAN networks. All physical -# networks listed in network_vlan_ranges on the server should have -# mappings to appropriate interfaces on each agent. -# -# physical_interface_mappings = -# Example: physical_interface_mappings = default:eth2 - - -# (StrOpt) Eswitch daemon end point connection url -# daemon_endpoint = 'tcp://127.0.0.1:60001' - -# The number of milliseconds the agent will wait for -# response on request to daemon -# request_timeout = 3000 - -# The number of retries the agent will send request -# to daemon before giving up -# retries = 3 - -# The backoff rate multiplier for waiting period between retries -# on request to daemon, i.e. value of 2 will double -# the request timeout each retry -# backoff_rate = 2 - -[agent] -# Agent's polling interval in seconds -# polling_interval = 2 diff --git a/neutron/cmd/eventlet/plugins/mlnx_neutron_agent.py b/neutron/cmd/eventlet/plugins/mlnx_neutron_agent.py deleted file mode 100644 index 5a3394a1c..000000000 --- a/neutron/cmd/eventlet/plugins/mlnx_neutron_agent.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2015 Mellanox Technologies, Ltd -# -# 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. - -from neutron.plugins.ml2.drivers.mlnx.agent import eswitch_neutron_agent - - -def main(): - eswitch_neutron_agent.main() diff --git a/neutron/plugins/ml2/drivers/mlnx/README b/neutron/plugins/ml2/drivers/mlnx/README deleted file mode 100644 index 10fcabae9..000000000 --- a/neutron/plugins/ml2/drivers/mlnx/README +++ /dev/null @@ -1,4 +0,0 @@ -The Neutron Mellanox plugin has been removed from the tree in Kilo. -This directory includes Mellanox L2 agent for MLNX mechanism driver. -For more details, please refer to the following link: -https://wiki.openstack.org/wiki/Mellanox-Neutron-ML2 \ No newline at end of file diff --git a/neutron/plugins/ml2/drivers/mlnx/__init__.py b/neutron/plugins/ml2/drivers/mlnx/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/neutron/plugins/ml2/drivers/mlnx/agent/__init__.py b/neutron/plugins/ml2/drivers/mlnx/agent/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/neutron/plugins/ml2/drivers/mlnx/agent/config.py b/neutron/plugins/ml2/drivers/mlnx/agent/config.py deleted file mode 100644 index 3a022a9bb..000000000 --- a/neutron/plugins/ml2/drivers/mlnx/agent/config.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2013 Mellanox Technologies, Ltd -# -# 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. - -from oslo_config import cfg - -from neutron.agent.common import config - -DEFAULT_INTERFACE_MAPPINGS = [] - -eswitch_opts = [ - cfg.ListOpt('physical_interface_mappings', - default=DEFAULT_INTERFACE_MAPPINGS, - help=_("List of :")), - cfg.StrOpt('daemon_endpoint', - default='tcp://127.0.0.1:60001', - help=_('eswitch daemon end point')), - cfg.IntOpt('request_timeout', default=3000, - help=_("The number of milliseconds the agent will wait for " - "response on request to daemon.")), - cfg.IntOpt('retries', default=3, - help=_("The number of retries the agent will send request " - "to daemon before giving up")), - cfg.IntOpt('backoff_rate', default=2, - help=_("backoff rate multiplier for waiting period between " - "retries for request to daemon, i.e. value of 2 will " - " double the request timeout each retry")), -] - -agent_opts = [ - cfg.IntOpt('polling_interval', default=2, - help=_("The number of seconds the agent will wait between " - "polling for local device changes.")), -] - - -cfg.CONF.register_opts(eswitch_opts, "ESWITCH") -cfg.CONF.register_opts(agent_opts, "AGENT") -config.register_agent_state_opts_helper(cfg.CONF) diff --git a/neutron/plugins/ml2/drivers/mlnx/agent/eswitch_neutron_agent.py b/neutron/plugins/ml2/drivers/mlnx/agent/eswitch_neutron_agent.py deleted file mode 100644 index 046c495e3..000000000 --- a/neutron/plugins/ml2/drivers/mlnx/agent/eswitch_neutron_agent.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2013 Mellanox Technologies, Ltd -# -# 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. - - -import sys - -from networking_mlnx.plugins.ml2.drivers.mlnx.agent import ( - mlnx_eswitch_neutron_agent) -from oslo_config import cfg -from oslo_log import log as logging - -from neutron.i18n import _LE, _LI -from neutron.common import config as common_config -from neutron.common import utils -from neutron.plugins.ml2.drivers.mlnx.agent import config # noqa - -LOG = logging.getLogger(__name__) - - -def main(): - common_config.init(sys.argv[1:]) - common_config.setup_logging() - - try: - interface_mappings = utils.parse_mappings( - cfg.CONF.ESWITCH.physical_interface_mappings) - except ValueError as e: - LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " - "Agent terminated!"), e) - sys.exit(1) - LOG.info(_LI("Interface mappings: %s"), interface_mappings) - - try: - agent = mlnx_eswitch_neutron_agent.MlnxEswitchNeutronAgent( - interface_mappings) - except Exception as e: - LOG.error(_LE("Failed on Agent initialisation : %s. " - "Agent terminated!"), e) - sys.exit(1) - - # Start everything. - LOG.info(_LI("Agent initialised successfully, now running... ")) - agent.run() - sys.exit(0) - - -if __name__ == '__main__': - main() diff --git a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py deleted file mode 100644 index 024a6411b..000000000 --- a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2014 OpenStack Foundation -# 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. - -from oslo_log import log - -from neutron.extensions import portbindings -from neutron.plugins.common import constants as p_constants -from neutron.plugins.ml2 import driver_api as api -from neutron.plugins.ml2.drivers import mech_agent - -LOG = log.getLogger(__name__) -AGENT_TYPE_MLNX = 'Mellanox plugin agent' -VIF_TYPE_IB_HOSTDEV = 'ib_hostdev' - - -class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): - """Attach to networks using Mellanox eSwitch L2 agent. - - The MellanoxMechanismDriver integrates the ml2 plugin with the - Mellanox eswitch L2 agent. Port binding with this driver requires the - Mellanox eswitch agent to be running on the port's host, and that agent - to have connectivity to at least one segment of the port's - network. - """ - - def __init__(self): - super(MlnxMechanismDriver, self).__init__( - agent_type=AGENT_TYPE_MLNX, - vif_type=VIF_TYPE_IB_HOSTDEV, - vif_details={portbindings.CAP_PORT_FILTER: False}, - supported_vnic_types=[portbindings.VNIC_DIRECT]) - - def get_allowed_network_types(self, agent=None): - return [p_constants.TYPE_LOCAL, p_constants.TYPE_FLAT, - p_constants.TYPE_VLAN] - - def get_mappings(self, agent): - return agent['configurations'].get('interface_mappings', {}) - - def try_to_bind_segment_for_agent(self, context, segment, agent): - if self.check_segment_for_agent(segment, agent): - if (segment[api.NETWORK_TYPE] in - (p_constants.TYPE_FLAT, p_constants.TYPE_VLAN)): - self.vif_details['physical_network'] = segment[ - 'physical_network'] - context.set_binding(segment[api.ID], - self.vif_type, - self.vif_details) diff --git a/neutron/plugins/ml2/drivers/mlnx/requirements.txt b/neutron/plugins/ml2/drivers/mlnx/requirements.txt deleted file mode 100644 index dacc9e910..000000000 --- a/neutron/plugins/ml2/drivers/mlnx/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -networking_mlnx diff --git a/neutron/tests/unit/plugins/ml2/drivers/mlnx/__init__.py b/neutron/tests/unit/plugins/ml2/drivers/mlnx/__init__.py deleted file mode 100644 index e69de29bb..000000000 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 deleted file mode 100644 index 7c18ff593..000000000 --- a/neutron/tests/unit/plugins/ml2/drivers/mlnx/test_mech_mlnx.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright (c) 2014 OpenStack Foundation -# 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. -import sys - -import mock -from neutron.extensions import portbindings -from neutron.plugins.ml2 import driver_api as api -from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base - -m_const_mock = mock.Mock() - -with mock.patch.dict(sys.modules, - {'networking_mlnx': mock.Mock(), - 'networking_mlnx.plugins': mock.Mock(), - 'networking_mlnx.plugins.ml2': mock.Mock(), - 'networking_mlnx.plugins.ml2.drivers': mock.Mock(), - 'networking_mlnx.plugins.ml2.drivers.mlnx': - m_const_mock}): - from neutron.plugins.ml2.drivers.mlnx import mech_mlnx - - -class MlnxMechanismBaseTestCase(base.AgentMechanismBaseTestCase): - VIF_TYPE = mech_mlnx.VIF_TYPE_IB_HOSTDEV - CAP_PORT_FILTER = False - AGENT_TYPE = mech_mlnx.AGENT_TYPE_MLNX - VNIC_TYPE = portbindings.VNIC_DIRECT - - GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'} - GOOD_CONFIGS = {'interface_mappings': GOOD_MAPPINGS} - - BAD_MAPPINGS = {'wrong_physical_network': 'wrong_bridge'} - BAD_CONFIGS = {'interface_mappings': BAD_MAPPINGS} - - AGENTS = [{'alive': True, - 'configurations': GOOD_CONFIGS, - 'host': 'host'}] - AGENTS_DEAD = [{'alive': False, - 'configurations': GOOD_CONFIGS, - 'host': 'dead_host'}] - AGENTS_BAD = [{'alive': False, - 'configurations': GOOD_CONFIGS, - 'host': 'bad_host_1'}, - {'alive': True, - 'configurations': BAD_CONFIGS, - 'host': 'bad_host_2'}] - - def setUp(self): - super(MlnxMechanismBaseTestCase, self).setUp() - self.driver = mech_mlnx.MlnxMechanismDriver() - self.driver.initialize() - - -class MlnxMechanismGenericTestCase(MlnxMechanismBaseTestCase, - base.AgentMechanismGenericTestCase): - pass - - -class MlnxMechanismLocalTestCase(MlnxMechanismBaseTestCase, - base.AgentMechanismLocalTestCase): - pass - - -class MlnxMechanismFlatTestCase(MlnxMechanismBaseTestCase, - base.AgentMechanismFlatTestCase): - pass - - -class MlnxMechanismVlanTestCase(MlnxMechanismBaseTestCase, - base.AgentMechanismVlanTestCase): - pass - - -class MlnxMechanismVifDetailsTestCase(MlnxMechanismBaseTestCase): - def setUp(self): - super(MlnxMechanismVifDetailsTestCase, self).setUp() - - def test_vif_details_contains_physical_net(self): - VLAN_SEGMENTS = [{api.ID: 'vlan_segment_id', - api.NETWORK_TYPE: 'vlan', - api.PHYSICAL_NETWORK: 'fake_physical_network', - api.SEGMENTATION_ID: 1234}] - - context = base.FakePortContext(self.AGENT_TYPE, - self.AGENTS, - VLAN_SEGMENTS, - portbindings.VNIC_DIRECT) - segment = VLAN_SEGMENTS[0] - agent = self.AGENTS[0] - self.driver.try_to_bind_segment_for_agent(context, segment, agent) - set({"physical_network": "fake_physical_network"}).issubset( - set(context._bound_vif_details.items())) diff --git a/setup.cfg b/setup.cfg index 2355cbd21..15cbd60f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -65,7 +65,6 @@ data_files = etc/neutron/plugins/ml2/ml2_conf_sriov.ini etc/neutron/plugins/ml2/openvswitch_agent.ini etc/neutron/plugins/ml2/sriov_agent.ini - etc/neutron/plugins/mlnx = etc/neutron/plugins/mlnx/mlnx_conf.ini etc/neutron/plugins/nuage = etc/neutron/plugins/nuage/nuage_plugin.ini etc/neutron/plugins/ovsvapp = etc/neutron/plugins/ovsvapp/ovsvapp_agent.ini scripts = @@ -83,7 +82,6 @@ console_scripts = neutron-linuxbridge-agent = neutron.plugins.ml2.drivers.linuxbridge.agent.linuxbridge_neutron_agent:main neutron-linuxbridge-cleanup = neutron.cmd.linuxbridge_cleanup:main neutron-metadata-agent = neutron.cmd.eventlet.agents.metadata:main - neutron-mlnx-agent = neutron.cmd.eventlet.plugins.mlnx_neutron_agent:main neutron-netns-cleanup = neutron.cmd.netns_cleanup:main neutron-ns-metadata-proxy = neutron.cmd.eventlet.agents.metadata_proxy:main neutron-ovsvapp-agent = neutron.cmd.eventlet.plugins.ovsvapp_neutron_agent:main @@ -139,7 +137,6 @@ neutron.ml2.mechanism_drivers = hyperv = neutron.plugins.ml2.drivers.hyperv.mech_hyperv:HypervMechanismDriver l2population = neutron.plugins.ml2.drivers.l2pop.mech_driver:L2populationMechanismDriver ofagent = neutron.plugins.ml2.drivers.ofagent.driver:OfagentMechanismDriver - mlnx = neutron.plugins.ml2.drivers.mlnx.mech_mlnx:MlnxMechanismDriver brocade = networking_brocade.vdx.ml2driver.mechanism_brocade:BrocadeMechanism brocade_fi_ni = neutron.plugins.ml2.drivers.brocade.fi_ni.mechanism_brocade_fi_ni:BrocadeFiNiMechanism fslsdn = neutron.plugins.ml2.drivers.freescale.mechanism_fslsdn:FslsdnMechanismDriver -- 2.45.2