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
This commit is contained in:
Pierre Hanselmann 2017-10-26 10:29:41 +02:00
parent 08026ec025
commit 1d9d363bba
5 changed files with 41 additions and 2 deletions

View File

@ -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 ca_file "$VMWAREAPI_CA_FILE"
iniset /$Q_PLUGIN_CONF_FILE dvs insecure "$VMWAREAPI_INSECURE" 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 dvs dvs_name "$VMWARE_DVS_NAME"
iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_extension_drivers vmware_dvs_dns
} }
function neutron_plugin_setup_interface_driver { function neutron_plugin_setup_interface_driver {

View File

@ -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.

View File

@ -48,6 +48,7 @@ neutron.ipam_drivers =
vmware_nsx.extension_drivers = vmware_nsx.extension_drivers =
vmware_nsxv_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverNSXv vmware_nsxv_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverNSXv
vmware_nsxv3_dns = vmware_nsx.extension_drivers.dns_integration:DNSExtensionDriverNSXv3 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 = vmware_nsx.neutron.nsxv.router_type_drivers =
shared = vmware_nsx.plugins.nsx_v.drivers.shared_router_driver:RouterSharedDriver shared = vmware_nsx.plugins.nsx_v.drivers.shared_router_driver:RouterSharedDriver
distributed = vmware_nsx.plugins.nsx_v.drivers.distributed_router_driver:RouterDistributedDriver distributed = vmware_nsx.plugins.nsx_v.drivers.distributed_router_driver:RouterDistributedDriver

View File

@ -322,6 +322,20 @@ class DNSExtensionDriverNSXv3(DNSExtensionDriver):
return False 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 DNS_DRIVER = None

View File

@ -29,7 +29,7 @@ from neutron.db import _utils as db_utils
from neutron.db import agentschedulers_db from neutron.db import agentschedulers_db
from neutron.db import allowedaddresspairs_db as addr_pair_db from neutron.db import allowedaddresspairs_db as addr_pair_db
from neutron.db import api as db_api 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 external_net_db
from neutron.db import l3_db from neutron.db import l3_db
from neutron.db.models import securitygroup as securitygroup_model # noqa 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 import vmware_nsx
from vmware_nsx._i18n import _ from vmware_nsx._i18n import _
from vmware_nsx.common import config # noqa 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 nsx_constants
from vmware_nsx.common import utils as c_utils from vmware_nsx.common import utils as c_utils
from vmware_nsx.db import db as nsx_db 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.dhcp_meta import modes as dhcpmeta_modes
from vmware_nsx.dvs import dvs from vmware_nsx.dvs import dvs
from vmware_nsx.dvs import dvs_utils from vmware_nsx.dvs import dvs_utils
from vmware_nsx.plugins.common import plugin as nsx_plugin_common
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -67,13 +69,14 @@ LOG = logging.getLogger(__name__)
@resource_extend.has_resource_extenders @resource_extend.has_resource_extenders
class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
agentschedulers_db.DhcpAgentSchedulerDbMixin, agentschedulers_db.DhcpAgentSchedulerDbMixin,
db_base_plugin_v2.NeutronDbPluginV2, nsx_plugin_common.NsxPluginBase,
dhcpmeta_modes.DhcpMetadataAccess, dhcpmeta_modes.DhcpMetadataAccess,
external_net_db.External_net_db_mixin, external_net_db.External_net_db_mixin,
l3_db.L3_NAT_dbonly_mixin, l3_db.L3_NAT_dbonly_mixin,
portbindings_db.PortBindingMixin, portbindings_db.PortBindingMixin,
portsecurity_db.PortSecurityDbMixin, portsecurity_db.PortSecurityDbMixin,
securitygroups_db.SecurityGroupDbMixin, securitygroups_db.SecurityGroupDbMixin,
dns_db.DNSDbMixin,
vlan_ext_db.Vlantransparent_db_mixin): vlan_ext_db.Vlantransparent_db_mixin):
supported_extension_aliases = ["allowed-address-pairs", supported_extension_aliases = ["allowed-address-pairs",
@ -99,8 +102,12 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
security_group=securitygroup_model.SecurityGroup, security_group=securitygroup_model.SecurityGroup,
security_group_rule=securitygroup_model.SecurityGroupRule) security_group_rule=securitygroup_model.SecurityGroupRule)
def __init__(self): def __init__(self):
self._extension_manager = nsx_managers.ExtensionManager()
super(NsxDvsV2, self).__init__() super(NsxDvsV2, self).__init__()
LOG.debug('Driver support: DVS: %s' % dvs_utils.dvs_is_enabled()) 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( neutron_extensions.append_api_extensions_path(
[vmware_nsx.NSX_EXT_PATH]) [vmware_nsx.NSX_EXT_PATH])
self.cfg_group = 'dvs' # group name for dvs section in nsx.ini 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): with db_api.context_manager.writer.using(context):
new_net = super(NsxDvsV2, self).create_network(context, new_net = super(NsxDvsV2, self).create_network(context,
network) network)
self._extension_manager.process_create_network(
context, net_data, new_net)
# Process port security extension # Process port security extension
self._process_network_port_security_create( self._process_network_port_security_create(
context, net_data, new_net) context, net_data, new_net)
@ -315,6 +324,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
with db_api.context_manager.writer.using(context): with db_api.context_manager.writer.using(context):
net_res = super(NsxDvsV2, self).update_network(context, id, net_res = super(NsxDvsV2, self).update_network(context, id,
network) network)
self._extension_manager.process_update_network(context, net_attrs,
net_res)
# Process port security extension # Process port security extension
self._process_network_port_security_update( self._process_network_port_security_update(
context, net_attrs, net_res) context, net_attrs, net_res)
@ -347,6 +358,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
with db_api.context_manager.writer.using(context): with db_api.context_manager.writer.using(context):
# First we allocate port in neutron database # First we allocate port in neutron database
neutron_db = super(NsxDvsV2, self).create_port(context, port) 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( port_security = self._get_network_security_binding(
context, neutron_db['network_id']) context, neutron_db['network_id'])
port_data[psec.PORTSECURITY] = port_security port_data[psec.PORTSECURITY] = port_security
@ -443,6 +456,8 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
context, port['port'], ret_port) context, port['port'], ret_port)
self._process_vnic_type(context, port['port'], id) self._process_vnic_type(context, port['port'], id)
LOG.debug("Updating port: %s", port) LOG.debug("Updating port: %s", port)
self._extension_manager.process_update_port(
context, port['port'], ret_port)
self._process_portbindings_create_and_update(context, self._process_portbindings_create_and_update(context,
port['port'], port['port'],
ret_port) ret_port)