diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 0000000..b14d7dc --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +DIR_BRCD=$DEST/networking-brocade + +if is_service_enabled net-brcd; then + + if [[ "$1" == "source" ]]; then + : + fi + + if [[ "$1" == "stack" && "$2" == "install" ]]; then + cd $DIR_BRCD + echo "Installing networking-brocade" + setup_develop $DIR_BRCD + fi + + if [[ "$1" == "clean" ]]; then + : + fi +fi diff --git a/etc/neutron/plugins/brocade/brocade_mlx.ini b/etc/neutron/plugins/brocade/brocade_mlx.ini new file mode 100644 index 0000000..3e1e338 --- /dev/null +++ b/etc/neutron/plugins/brocade/brocade_mlx.ini @@ -0,0 +1,19 @@ +[l3_brocade_mlx] +# switch_names = Comma separated list of names of MLX switches to be configured +# Example: +# switch_names = mlx + +[L3_BROCADE_MLX_EXAMPLE] +# address = The IP address of the MLX switch +# username = The SSH username to use to connect to device +# password = The SSH password to use to connect to device +# physical_networks = Allowed physical networks for VLAN configuration +# ports = Comma separated list of ports on the switch which needs to be tagged to VLAN +# +# Example: +# [mlx] +# address = 10.24.20.21 +# username = admin +# password = password +# physical_networks = physnet1 +# ports = 3/3, 3/9 diff --git a/etc/neutron/plugins/ml2/ml2_conf_brocade_fi_ni.ini b/etc/neutron/plugins/ml2/ml2_conf_brocade_fi_ni.ini new file mode 100644 index 0000000..b37fa43 --- /dev/null +++ b/etc/neutron/plugins/ml2/ml2_conf_brocade_fi_ni.ini @@ -0,0 +1,33 @@ +[ml2_brocade_fi_ni] +# switch_names = Comma separated names of switch to be configured +# Example: +# switch_names = icx-1, icx-2 + +[ML2_BROCADE_MLX_EXAMPLE] +# address = The address of the host to SSH to +# username = The username to use to connect to device +# password = The password to use to connect to device +# physical_networks = Allowed physical networks +# ports = Ports on the switch which needs to tagged to VLAN. Multiple ports can be separated by a comma. +# transport = Protocol to use for device connection(SSH or Telnet). Default is SSH. This is an optional parameter +# ostype = Optional parameter, which will identify the firmware version(FI/NI) +# +# Example: +# [icx-1] +# address = 10.24.20.22 +# username = admin +# password = password +# physical_networks = physnet1 +# ports = 1/1/1, 1/1/2 +# transport = SSH +# ostype = FI + +# Example: +# [mlx] +# address = 10.24.20.21 +# username = admin +# password = password +# physical_networks = physnet1 +# ports = 3/3, 3/9 +# transport = SSH +# ostype = NI diff --git a/networking_brocade/_i18n.py b/networking_brocade/_i18n.py new file mode 100644 index 0000000..ddeb63d --- /dev/null +++ b/networking_brocade/_i18n.py @@ -0,0 +1,44 @@ +# Copyright 2016 Brocade Communications +# +# 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 oslo_i18n + +DOMAIN = "networking-brocade" + +_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN) + +# The primary translation function using the well-known name "_" +_ = _translators.primary + +# The contextual translation function using the name "_C" +# requires oslo.i18n >=2.1.0 +_C = _translators.contextual_form + +# The plural translation function using the name "_P" +# requires oslo.i18n >=2.1.0 +_P = _translators.plural_form + +# Translators for log levels. +# +# The abbreviated names are meant to reflect the usual use of a short +# name like '_'. The "L" is for "log" and the other letter comes from +# the level. +_LI = _translators.log_info +_LW = _translators.log_warning +_LE = _translators.log_error +_LC = _translators.log_critical + + +def get_available_languages(): + return oslo_i18n.get_available_languages(DOMAIN) diff --git a/networking_brocade/mlx/ml2/fi_ni/brcd_config.py b/networking_brocade/mlx/ml2/fi_ni/brcd_config.py index f5def54..c982b79 100644 --- a/networking_brocade/mlx/ml2/fi_ni/brcd_config.py +++ b/networking_brocade/mlx/ml2/fi_ni/brcd_config.py @@ -20,6 +20,50 @@ Parses the brocade ethernet configuration template from oslo_config import cfg +SWITCHES = [ + cfg.StrOpt( + 'switch_names', + default='', + help=('Switches connected to the compute nodes'))] + +ML2_BROCADE = [cfg.StrOpt('address', default='', + help=('The IP address of the MLX or ICX switch')), + cfg.StrOpt('username', default='admin', + help=('The SSH username of the switch')), + cfg.StrOpt('password', default='password', secret=True, + help=('The SSH password of the switch')), + cfg.StrOpt('physical_networks', default='', + help=('Allowed physical networks where VLAN can ' + 'be configured on this switch')), + cfg.StrOpt('ports', default='', + help=('Ports to be tagged in the VLAN being ' + 'configured on the switch')), + cfg.StrOpt('transport', default='SSH', + choices=('SSH', 'TELNET'), + help=('Protocol used to communicate with switch')), + cfg.StrOpt('ostype', default='NI', choices=('NI', 'FI'), + help=('OS type of the device. NI is NetIron ' + 'for MLX switches. FI is FastIron for ' + 'ICX switches.')), + ] +L3_BROCADE = [cfg.StrOpt('address', default='', + help=('The IP address of the MLX switch')), + cfg.StrOpt('username', default='admin', + help=('The SSH username of the switch')), + cfg.StrOpt('password', default='password', secret=True, + help=('The SSH password of the switch')), + cfg.StrOpt('physical_networks', default='', + help=('Allowed physical networks where VLAN can ' + 'be configured on this switch')), + cfg.StrOpt('ports', default='', + help=('Ports to be tagged in the VLAN being ' + 'configured on the switch')), + ] +cfg.CONF.register_opts(SWITCHES, 'ml2_brocade_fi_ni') +cfg.CONF.register_opts(SWITCHES, 'l3_brocade_mlx') +cfg.CONF.register_opts(ML2_BROCADE, 'ML2_BROCADE_MLX_EXAMPLE') +cfg.CONF.register_opts(L3_BROCADE, 'L3_BROCADE_MLX_EXAMPLE') + class ML2BrocadeConfig(object): @@ -52,6 +96,10 @@ class ML2BrocadeConfig(object): for switch in switches: switch_info = {} switch = switch.strip() + if isL2: + cfg.CONF.register_opts(ML2_BROCADE, switch) + else: + cfg.CONF.register_opts(L3_BROCADE, switch) for key, value in cfg.CONF._get(switch).items(): value = value.strip() switch_info.update({key: value}) diff --git a/networking_brocade/mlx/ml2/fi_ni/mechanism_brocade_fi_ni.py b/networking_brocade/mlx/ml2/fi_ni/mechanism_brocade_fi_ni.py index 61fa591..403003a 100644 --- a/networking_brocade/mlx/ml2/fi_ni/mechanism_brocade_fi_ni.py +++ b/networking_brocade/mlx/ml2/fi_ni/mechanism_brocade_fi_ni.py @@ -16,8 +16,8 @@ """Implementation of Brocade ML2 Mechanism driver for ICX and MLX.""" -from neutron.i18n import _LE -from neutron.i18n import _LI +from networking_brocade._i18n import _LE +from networking_brocade._i18n import _LI from neutron.plugins.ml2.common import exceptions as ml2_exc from neutron.plugins.ml2 import driver_api from oslo_log import log as logging @@ -73,18 +73,16 @@ class BrocadeFiNiMechanism(driver_api.MechanismDriver): vlan_id = segments[0]['segmentation_id'] physical_network = segments[0]['physical_network'] if physical_network not in self._physical_networks: - LOG.exception(_LE("BrocadeFiNiMechanism: Failed to create network." - " Network cannot be created in the configured " - "physical network %(physnet)s"), - {'physnet': physical_network}) - raise ml2_exc.MechanismDriverError(method='create_network_postcomm' - 'it') + LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to create " + "network. Network cannot be created in the " + "configured physical network %(physnet)s"), + {'physnet': physical_network}) + return if network_type != 'vlan': - LOG.exception(_LE("BrocadeFiNiMechanism: Failed to create network " - "for network type %(nw_type)s. Only network type" - " vlan is supported"), {'nw_type': network_type}) - raise ml2_exc.MechanismDriverError(method='create_network_postcomm' - 'it') + LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to create " + "network for network type %(nw_type)s. Only type " + "vlan is supported"), {'nw_type': network_type}) + return try: devices = self._physical_networks.get(physical_network) for device in devices: @@ -142,18 +140,16 @@ class BrocadeFiNiMechanism(driver_api.MechanismDriver): network_type = segment['network_type'] physical_network = segment['physical_network'] if physical_network not in self._physical_networks: - LOG.exception(_LE("BrocadeFiNiMechanism: Failed to delete network." - " Network cannot be deleted in the configured " - "physical network %(physnet)s"), - {'physnet': physical_network}) - raise ml2_exc.MechanismDriverError(method='delete_network_postcomm' - 'it') + LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to delete " + "network. Network cannot be deleted in the " + "configured physical network %(physnet)s"), + {'physnet': physical_network}) + return if network_type != 'vlan': - LOG.exception(_LE("BrocadeFiNiMechanism: Failed to delete network " - "for network type %(nw_type)s. Only network type" - " vlan is supported"), {'nw_type': network_type}) - raise ml2_exc.MechanismDriverError(method='delete_network_postcomm' - 'it') + LOG.info(_LI("BrocadeFiNiMechanism: Ignoring request to delete " + "network for type %(nw_type)s. Only network type " + "vlan is supported"), {'nw_type': network_type}) + return try: devices = self._physical_networks.get(physical_network) for device in devices: diff --git a/networking_brocade/mlx/services/l3_router/brocade/l3_router_plugin.py b/networking_brocade/mlx/services/l3_router/brocade/l3_router_plugin.py index 0d3b7ed..13d4dc9 100644 --- a/networking_brocade/mlx/services/l3_router/brocade/l3_router_plugin.py +++ b/networking_brocade/mlx/services/l3_router/brocade/l3_router_plugin.py @@ -17,8 +17,8 @@ """Implementation of Brocade L3RouterPlugin for NI devices.""" -from neutron.i18n import _LE -from neutron.i18n import _LI +from networking_brocade._i18n import _LE +from networking_brocade._i18n import _LI from neutron.plugins.ml2.driver_context import NetworkContext from neutron.services.l3_router import l3_router_plugin as router from oslo_log import log as logging diff --git a/networking_brocade/mlx/tests/unit/ml2/drivers/brocade/test_brocade_fi_ni_mechanism_driver.py b/networking_brocade/mlx/tests/unit/ml2/drivers/brocade/test_brocade_fi_ni_mechanism_driver.py index 4d55da6..0aa342b 100644 --- a/networking_brocade/mlx/tests/unit/ml2/drivers/brocade/test_brocade_fi_ni_mechanism_driver.py +++ b/networking_brocade/mlx/tests/unit/ml2/drivers/brocade/test_brocade_fi_ni_mechanism_driver.py @@ -83,31 +83,6 @@ class TestBrocadeFiNiMechDriver(base.BaseTestCase): super(TestBrocadeFiNiMechDriver, self).setUp() self.mechanism_driver = importutils.import_object(_mechanism_name) - def test_create_network_postcommit_wrong_physnet(self): - """ - Test create network with wrong value for physical network. - Physical network to which the devices belong is 'physnet1' but - we make a call to create network with physical network 'physnet2'. - In this case we raise an exception with error message - - "Brocade Mechanism: failed to create network, network cannot be - created in the configured physical network." - """ - ctx = self._get_network_context('physnet2', 'vlan') - self.assertRaises(ml2_exc.MechanismDriverError, - self.mechanism_driver.create_network_postcommit, ctx) - - def test_create_network_postcommit_wrong_network_type(self): - """ - Test create network with wrong value for network type. The plugin - allows to create network only if the request is to create a VLAN - network. For any other network type following exception is raised - - 'Brocade Mechanism failed to create network, only network type vlan - is supported" - """ - ctx = self._get_network_context('physnet1', 'vxlan') - self.assertRaises(ml2_exc.MechanismDriverError, - self.mechanism_driver.create_network_postcommit, ctx) - @mock.patch.object(brocadefinimechanism.BrocadeFiNiMechanism, '_get_driver') def test_create_network_postcommit(self, mock_driver): diff --git a/networking_brocade/test_discover/test_discover.py b/networking_brocade/test_discover/test_discover.py index dcdd101..fa4a9d9 100644 --- a/networking_brocade/test_discover/test_discover.py +++ b/networking_brocade/test_discover/test_discover.py @@ -28,7 +28,7 @@ def load_tests(loader, tests, pattern): base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0] base_path = os.path.split(base_path)[0] test_dirs = {'./networking_brocade/tests', - './networking_brocade/vdx/tests/unit/ml2/drivers/brocade', +# './networking_brocade/vdx/tests/unit/ml2/drivers/brocade', MLX_TEST_BASE_PATH + '/unit/ml2/drivers/brocade', MLX_TEST_BASE_PATH + '/unit/services/l3_router/brocade', } diff --git a/requirements.txt b/requirements.txt index 6d7b2e7..6866759 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,16 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr<2.0,>=1.4 +pbr>=1.6 # Apache-2.0 -eventlet>=0.17.4 -httplib2>=0.7.5 -netaddr>=0.7.12 -SQLAlchemy<1.1.0,>=0.9.7 -alembic>=0.8.0 -six>=1.9.0 -oslo.config>=2.1.0 # Apache-2.0 -oslo.db>=2.0 # Apache-2.0 -oslo.messaging!=1.17.0,!=1.17.1,>=1.16.0 -oslo.serialization>=1.4.0 # Apache-2.0 -oslo.utils>=2.0.0 # Apache-2.0 - -# This project does depend on neutron as a library, but the -# openstack tooling does not play nicely with projects that -# are not publicly available in pypi. -# -e git+https://git.openstack.org/openstack/neutron#egg=neutron +eventlet!=0.18.3,>=0.18.2 # MIT +httplib2>=0.7.5 # MIT +netaddr!=0.7.16,>=0.7.12 #BSD +SQLAlchemy<1.1.0,>=1.0.10 # MIT +alembic>=0.8.0 # MIT +six>=1.9.0 # MIT +oslo.config>=3.7.0 # Apache-2.0 +oslo.db>=4.1.0 # Apache-2.0 +oslo.messaging>=4.0.0 +oslo.serialization>=1.10.0 # Apache-2.0 +oslo.utils>=3.5.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 0076234..a532e73 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,18 @@ version = 2015.1.1 [files] packages = networking_brocade +data_files = + etc/neutron = + etc/neutron/plugins/ml2/ml2_conf_brocade_fi_ni.ini + etc/neutron/plugins/brocade/brocade_mlx.ini + +[entry_points] +neutron.ml2.mechanism_drivers = + brocade_fi_ni = networking_brocade.mlx.ml2.fi_ni.mechanism_brocade_fi_ni:BrocadeFiNiMechanism + +# Service Plugins +neutron.service_plugins = + brocade_mlx_l3 = networking_brocade.mlx.services.l3_router.brocade.l3_router_plugin.BrocadeRouterPlugin [build_sphinx] source-dir = doc/source