Merge "NSX|V3: VPN connection status update"
This commit is contained in:
commit
9d99f0f06d
@ -232,6 +232,11 @@ Add neutron-vpnaas repo as an external repository and configure following flags
|
|||||||
[[local|localrc]]
|
[[local|localrc]]
|
||||||
enable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas
|
enable_plugin neutron-vpnaas https://git.openstack.org/openstack/neutron-vpnaas
|
||||||
NEUTRON_VPNAAS_SERVICE_PROVIDER=VPN:vmware:vmware_nsx.services.vpnaas.nsxv3.ipsec_driver.NSXv3IPsecVpnDriver:default
|
NEUTRON_VPNAAS_SERVICE_PROVIDER=VPN:vmware:vmware_nsx.services.vpnaas.nsxv3.ipsec_driver.NSXv3IPsecVpnDriver:default
|
||||||
|
Q_SERVICE_PLUGIN_CLASSES+=,vmware_nsx_vpnaas
|
||||||
|
|
||||||
|
[[post-config|$NEUTRON_CONF]]
|
||||||
|
[DEFAULT]
|
||||||
|
api_extensions_path = $DEST/neutron-vpnaas/neutron_vpnaas/extensions
|
||||||
|
|
||||||
|
|
||||||
NSX-TVD
|
NSX-TVD
|
||||||
|
@ -50,6 +50,7 @@ neutron.service_plugins =
|
|||||||
vmware_nsxtvd_l2gw = vmware_nsx.services.l2gateway.nsx_tvd.plugin:L2GatewayPlugin
|
vmware_nsxtvd_l2gw = vmware_nsx.services.l2gateway.nsx_tvd.plugin:L2GatewayPlugin
|
||||||
vmware_nsxtvd_qos = vmware_nsx.services.qos.nsx_tvd.plugin:QoSPlugin
|
vmware_nsxtvd_qos = vmware_nsx.services.qos.nsx_tvd.plugin:QoSPlugin
|
||||||
vmware_nsxtvd_vpnaas = vmware_nsx.services.vpnaas.nsx_tvd.plugin:VPNPlugin
|
vmware_nsxtvd_vpnaas = vmware_nsx.services.vpnaas.nsx_tvd.plugin:VPNPlugin
|
||||||
|
vmware_nsx_vpnaas = vmware_nsx.services.vpnaas.nsx_plugin:NsxVPNPlugin
|
||||||
neutron.qos.notification_drivers =
|
neutron.qos.notification_drivers =
|
||||||
vmware_nsxv3_message_queue = vmware_nsx.services.qos.nsx_v3.message_queue:NsxV3QosNotificationDriver
|
vmware_nsxv3_message_queue = vmware_nsx.services.qos.nsx_v3.message_queue:NsxV3QosNotificationDriver
|
||||||
neutron.ipam_drivers =
|
neutron.ipam_drivers =
|
||||||
|
65
vmware_nsx/services/vpnaas/nsx_plugin.py
Normal file
65
vmware_nsx/services/vpnaas/nsx_plugin.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Copyright 2018 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 oslo_log import log as logging
|
||||||
|
|
||||||
|
from neutron_vpnaas.services.vpn import plugin
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class NsxVPNPlugin(plugin.VPNDriverPlugin):
|
||||||
|
"""NSX plugin for VPNaaS.
|
||||||
|
|
||||||
|
This plugin overrides get connection/s calls to issue a status update
|
||||||
|
before them, and make sure the connections status is up to date
|
||||||
|
"""
|
||||||
|
def _update_nsx_connection_status(self, context, ipsec_site_conn_id):
|
||||||
|
driver = self.drivers[self.default_provider]
|
||||||
|
if hasattr(driver, 'get_ipsec_site_connection_status'):
|
||||||
|
status = driver.get_ipsec_site_connection_status(
|
||||||
|
context, ipsec_site_conn_id)
|
||||||
|
if status:
|
||||||
|
self._update_connection_status(context, ipsec_site_conn_id,
|
||||||
|
status, False)
|
||||||
|
|
||||||
|
def update_all_connection_status(self, context):
|
||||||
|
connections = super(NsxVPNPlugin, self).get_ipsec_site_connections(
|
||||||
|
context)
|
||||||
|
if not connections:
|
||||||
|
return
|
||||||
|
# TODO(asarfaty): This will not scale well. Should use a bulk action
|
||||||
|
# instead for the NSX api
|
||||||
|
for connection in connections:
|
||||||
|
self._update_nsx_connection_status(context, connection['id'])
|
||||||
|
|
||||||
|
def get_ipsec_site_connection(self, context,
|
||||||
|
ipsec_site_conn_id, fields=None):
|
||||||
|
# update connection status
|
||||||
|
if not fields or 'status' in fields:
|
||||||
|
self._update_nsx_connection_status(context, ipsec_site_conn_id)
|
||||||
|
|
||||||
|
# call super
|
||||||
|
return super(NsxVPNPlugin, self).get_ipsec_site_connection(
|
||||||
|
context, ipsec_site_conn_id, fields=fields)
|
||||||
|
|
||||||
|
def get_ipsec_site_connections(self, context, filters=None, fields=None):
|
||||||
|
# update connection status
|
||||||
|
if not fields or 'status' in fields:
|
||||||
|
self.update_all_connection_status(context)
|
||||||
|
|
||||||
|
# call super
|
||||||
|
return super(NsxVPNPlugin, self).get_ipsec_site_connections(
|
||||||
|
context, filters=filters, fields=fields)
|
@ -98,3 +98,11 @@ class NSXIPsecVpnDriver(service_drivers.VpnDriver):
|
|||||||
return d._generate_ipsecvpn_firewall_rules(
|
return d._generate_ipsecvpn_firewall_rules(
|
||||||
plugin_type, context, **kargs)
|
plugin_type, context, **kargs)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def get_ipsec_site_connection_status(self, context, ipsec_site_conn_id):
|
||||||
|
# Currently only NSX-T supports it. In the future we will need to
|
||||||
|
# decide on the driver by the tenant
|
||||||
|
driver = self.drivers.get(projectpluginmap.NsxPlugins.NSX_T)
|
||||||
|
if driver and hasattr(driver, 'get_ipsec_site_connection_status'):
|
||||||
|
return driver.get_ipsec_site_connection_status(
|
||||||
|
context, ipsec_site_conn_id)
|
||||||
|
@ -13,14 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron_vpnaas.services.vpn import plugin
|
|
||||||
|
|
||||||
from vmware_nsx.plugins.nsx import utils as tvd_utils
|
from vmware_nsx.plugins.nsx import utils as tvd_utils
|
||||||
|
from vmware_nsx.services.vpnaas import nsx_plugin
|
||||||
|
|
||||||
|
|
||||||
@tvd_utils.filter_plugins
|
@tvd_utils.filter_plugins
|
||||||
class VPNPlugin(plugin.VPNDriverPlugin):
|
class VPNPlugin(nsx_plugin.NsxVPNPlugin):
|
||||||
"""NSX-TV plugin for QoS.
|
"""NSX-TV plugin for VPNaaS.
|
||||||
|
|
||||||
This plugin adds separation between T/V instances
|
This plugin adds separation between T/V instances
|
||||||
"""
|
"""
|
||||||
|
@ -493,6 +493,24 @@ class NSXv3IPsecVpnDriver(service_drivers.VpnDriver):
|
|||||||
policy_rules=rules,
|
policy_rules=rules,
|
||||||
enabled=enabled)
|
enabled=enabled)
|
||||||
|
|
||||||
|
def get_ipsec_site_connection_status(self, context, ipsec_site_conn_id):
|
||||||
|
mapping = db.get_nsx_vpn_connection_mapping(
|
||||||
|
context.session, ipsec_site_conn_id)
|
||||||
|
if not mapping or not mapping['session_id']:
|
||||||
|
LOG.info("Couldn't find NSX session for VPN connection %s",
|
||||||
|
ipsec_site_conn_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
status_result = self._nsx_vpn.session.get_status(mapping['session_id'])
|
||||||
|
if status_result and 'session_status' in status_result:
|
||||||
|
status = status_result['session_status']
|
||||||
|
# NSX statuses are UP, DOWN, DEGRADE
|
||||||
|
# VPNaaS connection status should be ACTIVE or DOWN
|
||||||
|
if status == 'UP':
|
||||||
|
return 'ACTIVE'
|
||||||
|
elif status == 'DOWN' or status == 'DEGRADED':
|
||||||
|
return 'DOWN'
|
||||||
|
|
||||||
def _delete_session(self, session_id):
|
def _delete_session(self, session_id):
|
||||||
self._nsx_vpn.session.delete(session_id)
|
self._nsx_vpn.session.delete(session_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user