Add support for L2 gateway service plugin

This patch adds the service plugin module which integrates the
networking-l2gw APIs with NSX. This module is the common framework
for the Layer 2 gateway support for NSX-T and NSX-V backends.
The corresponding backend drivers will be controlled via the config
parameter introduced here. This parameter will be configured with the
class path to the backend driver. Backend drivers will be responsible
for adding backend-specific logic. The corresponding backend drivers
for NSX-T and NSX-V will be addressed in separate follow up patches.

Change-Id: If997df17a1379a3775d29c1377f0f4e1ce9be328
Partial-bug: #1481087
This commit is contained in:
Abhishek Raut 2015-08-01 01:13:22 -07:00
parent b27bc19421
commit e760c30a6f
5 changed files with 75 additions and 1 deletions

View File

@ -24,6 +24,8 @@ packages =
[entry_points]
console_scripts =
neutron-check-nsx-config = vmware_nsx.neutron.plugins.vmware.check_nsx_config:main
neutron.service_plugins =
vmware_nsx_l2gw = vmware_nsx.neutron.services.l2gateway.plugin:NsxL2GatewayPlugin
vmware_nsx.neutron.nsxv.router_type_drivers =
shared = vmware_nsx.neutron.plugins.vmware.plugins.nsx_v_drivers.shared_router_driver:RouterSharedDriver
distributed = vmware_nsx.neutron.plugins.vmware.plugins.nsx_v_drivers.distributed_router_driver:RouterDistributedDriver

View File

@ -169,7 +169,9 @@ nsx_v3_opts = [
cfg.StrOpt('nsx_manager',
help=_('IP address of the NSX manager')),
cfg.StrOpt('default_edge_cluster_uuid',
help=_("Default edge cluster identifier"))]
help=_("Default edge cluster identifier")),
cfg.StrOpt('nsx_l2gw_driver',
help=_("Class path for the L2 gateway backend driver"))]
DEFAULT_STATUS_CHECK_INTERVAL = 2000
DEFAULT_MINIMUM_POOLED_EDGES = 1

View File

View File

@ -0,0 +1,70 @@
# Copyright 2015 VMware, 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.
from networking_l2gw.db.l2gateway import l2gateway_db
from networking_l2gw.services.l2gateway.common import constants as l2gw_const
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from vmware_nsx.neutron.plugins.vmware.common import config # noqa
LOG = logging.getLogger(__name__)
class NsxL2GatewayPlugin(l2gateway_db.L2GatewayMixin):
"""Service plugin for VMware NSX to implement Neutron's L2 gateway API."""
supported_extension_aliases = ["l2-gateway", "l2-gateway-connection"]
_methods_to_delegate = ["create_l2_gateway", "get_l2_gateway",
"delete_l2_gateway", "get_l2_gateways",
"update_l2_gateway",
"create_l2_gateway_connection",
"get_l2_gateway_connection",
"get_l2_gateway_connections",
"update_l2_gateway_connection",
"delete_l2_gateway_connection"]
def __init__(self):
"""Initialize service plugin and load backend driver."""
super(NsxL2GatewayPlugin, self).__init__()
LOG.debug("Starting service plugin for NSX L2Gateway")
self._nsx_l2gw_driver = cfg.CONF.nsx_v3.nsx_l2gw_driver
if not getattr(self, "_nsx_l2gw_driver"):
raise cfg.RequiredOptError("nsx_l2gw_driver", "nsx_v3")
self._driver = importutils.import_object(self._nsx_l2gw_driver)
@staticmethod
def get_plugin_type():
"""Get type of the plugin."""
return l2gw_const.L2GW
@staticmethod
def get_plugin_description():
"""Get description of the plugin."""
return l2gw_const.L2_GATEWAY_SERVICE_PLUGIN
def __getattribute__(self, name):
"""Delegate L2GW API calls to the driver class."""
methods = object.__getattribute__(self, "_methods_to_delegate")
if name in methods:
# If method is delegated, return the driver class method.
return getattr(object.__getattribute__(self, "_driver"), name)
else:
# Else return our own method.
return object.__getattribute__(self, name)