From 1d9d363bba8c73aa764aec5cad9d4f4fc867a318 Mon Sep 17 00:00:00 2001 From: Pierre Hanselmann Date: Thu, 26 Oct 2017 10:29:41 +0200 Subject: [PATCH] DVS: Add support for dns-integration extension One can enable DNS integration for the upstream neutron DNS integration extension by setting: nsx_extension_drivers = vmware_dvs_dns Closes-Bug: #1727626 Change-Id: If776d21679acfa2abf8018a8f6f19b58be24cb4b --- devstack/lib/vmware_dvs | 1 + .../dvs_dns_integration-831224f15acbc728.yaml | 8 ++++++++ setup.cfg | 1 + .../extension_drivers/dns_integration.py | 14 ++++++++++++++ vmware_nsx/plugins/dvs/plugin.py | 19 +++++++++++++++++-- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/dvs_dns_integration-831224f15acbc728.yaml diff --git a/devstack/lib/vmware_dvs b/devstack/lib/vmware_dvs index d6038cc995..2d7f9d36db 100644 --- a/devstack/lib/vmware_dvs +++ b/devstack/lib/vmware_dvs @@ -101,6 +101,7 @@ function neutron_plugin_configure_service { iniset /$Q_PLUGIN_CONF_FILE dvs ca_file "$VMWAREAPI_CA_FILE" iniset /$Q_PLUGIN_CONF_FILE dvs insecure "$VMWAREAPI_INSECURE" iniset /$Q_PLUGIN_CONF_FILE dvs dvs_name "$VMWARE_DVS_NAME" + iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_extension_drivers vmware_dvs_dns } function neutron_plugin_setup_interface_driver { diff --git a/releasenotes/notes/dvs_dns_integration-831224f15acbc728.yaml b/releasenotes/notes/dvs_dns_integration-831224f15acbc728.yaml new file mode 100644 index 0000000000..7f4f0a1156 --- /dev/null +++ b/releasenotes/notes/dvs_dns_integration-831224f15acbc728.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + One can enable DNS integration for the upstream neutron for + VMware NSX-DVS. DNS integration extension by setting: + nsx_extension_drivers = vmware_dvs_dns + in the default section of neutron.conf. + diff --git a/setup.cfg b/setup.cfg index 6205443c6b..bb01ad6f5d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,6 +48,7 @@ neutron.ipam_drivers = vmware_nsx.extension_drivers = vmware_nsxv_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverNSXv vmware_nsxv3_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverNSXv3 + vmware_dvs_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverDVS vmware_nsx.neutron.nsxv.router_type_drivers = shared = vmware_nsx.plugins.nsx_v.drivers.shared_router_driver:RouterSharedDriver distributed = vmware_nsx.plugins.nsx_v.drivers.distributed_router_driver:RouterDistributedDriver diff --git a/vmware_nsx/extension_drivers/dns_integration.py b/vmware_nsx/extension_drivers/dns_integration.py index cae8b2a78f..84b6e48355 100644 --- a/vmware_nsx/extension_drivers/dns_integration.py +++ b/vmware_nsx/extension_drivers/dns_integration.py @@ -322,6 +322,20 @@ class DNSExtensionDriverNSXv3(DNSExtensionDriver): return False +class DNSExtensionDriverDVS(DNSExtensionDriver): + + def initialize(self): + LOG.info("DNSExtensionDriverDVS initialization complete") + + def external_dns_not_needed(self, context, network): + dns_driver = _get_dns_driver() + if not dns_driver: + return True + if network['router:external']: + return True + return False + + DNS_DRIVER = None diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index b1a2ddaaf7..c3e73cc355 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -29,7 +29,7 @@ from neutron.db import _utils as db_utils from neutron.db import agentschedulers_db from neutron.db import allowedaddresspairs_db as addr_pair_db from neutron.db import api as db_api -from neutron.db import db_base_plugin_v2 +from neutron.db import dns_db from neutron.db import external_net_db from neutron.db import l3_db from neutron.db.models import securitygroup as securitygroup_model # noqa @@ -53,6 +53,7 @@ from neutron_lib import exceptions as n_exc import vmware_nsx from vmware_nsx._i18n import _ from vmware_nsx.common import config # noqa +from vmware_nsx.common import managers as nsx_managers from vmware_nsx.common import nsx_constants from vmware_nsx.common import utils as c_utils from vmware_nsx.db import db as nsx_db @@ -60,6 +61,7 @@ from vmware_nsx.db import nsxv_db from vmware_nsx.dhcp_meta import modes as dhcpmeta_modes from vmware_nsx.dvs import dvs from vmware_nsx.dvs import dvs_utils +from vmware_nsx.plugins.common import plugin as nsx_plugin_common LOG = logging.getLogger(__name__) @@ -67,13 +69,14 @@ LOG = logging.getLogger(__name__) @resource_extend.has_resource_extenders class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, agentschedulers_db.DhcpAgentSchedulerDbMixin, - db_base_plugin_v2.NeutronDbPluginV2, + nsx_plugin_common.NsxPluginBase, dhcpmeta_modes.DhcpMetadataAccess, external_net_db.External_net_db_mixin, l3_db.L3_NAT_dbonly_mixin, portbindings_db.PortBindingMixin, portsecurity_db.PortSecurityDbMixin, securitygroups_db.SecurityGroupDbMixin, + dns_db.DNSDbMixin, vlan_ext_db.Vlantransparent_db_mixin): supported_extension_aliases = ["allowed-address-pairs", @@ -99,8 +102,12 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, security_group=securitygroup_model.SecurityGroup, security_group_rule=securitygroup_model.SecurityGroupRule) def __init__(self): + self._extension_manager = nsx_managers.ExtensionManager() super(NsxDvsV2, self).__init__() LOG.debug('Driver support: DVS: %s' % dvs_utils.dvs_is_enabled()) + self._extension_manager.initialize() + self.supported_extension_aliases.extend( + self._extension_manager.extension_aliases()) neutron_extensions.append_api_extensions_path( [vmware_nsx.NSX_EXT_PATH]) self.cfg_group = 'dvs' # group name for dvs section in nsx.ini @@ -189,6 +196,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, with db_api.context_manager.writer.using(context): new_net = super(NsxDvsV2, self).create_network(context, network) + self._extension_manager.process_create_network( + context, net_data, new_net) # Process port security extension self._process_network_port_security_create( context, net_data, new_net) @@ -315,6 +324,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, with db_api.context_manager.writer.using(context): net_res = super(NsxDvsV2, self).update_network(context, id, network) + self._extension_manager.process_update_network(context, net_attrs, + net_res) # Process port security extension self._process_network_port_security_update( context, net_attrs, net_res) @@ -347,6 +358,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, with db_api.context_manager.writer.using(context): # First we allocate port in neutron database neutron_db = super(NsxDvsV2, self).create_port(context, port) + self._extension_manager.process_create_port( + context, port_data, neutron_db) port_security = self._get_network_security_binding( context, neutron_db['network_id']) port_data[psec.PORTSECURITY] = port_security @@ -443,6 +456,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, context, port['port'], ret_port) self._process_vnic_type(context, port['port'], id) LOG.debug("Updating port: %s", port) + self._extension_manager.process_update_port( + context, port['port'], ret_port) self._process_portbindings_create_and_update(context, port['port'], ret_port)