NSX|P metadata proxy support
Using the passthrough api with the same code as the V3 plugin Also updatinh the availability zones initialization to support this In addition, add some native dhcp & mdproxy tests (some of which are still skipped) Change-Id: I46c50a2115dc092f3abd309546cb0e2d9750d711
This commit is contained in:
parent
74f3831027
commit
23849cf537
|
@ -93,13 +93,45 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone):
|
|||
# Should be implemented by children
|
||||
pass
|
||||
|
||||
def _translate_dhcp_profile(self, nsxlib, search_scope=None):
|
||||
if self.dhcp_profile:
|
||||
dhcp_id = None
|
||||
if search_scope:
|
||||
# Find the TZ by its tag
|
||||
dhcp_id = nsxlib.get_id_by_resource_and_tag(
|
||||
nsxlib.native_dhcp_profile.resource_type,
|
||||
search_scope,
|
||||
self.dhcp_profile)
|
||||
if not dhcp_id:
|
||||
dhcp_id = nsxlib.native_dhcp_profile.get_id_by_name_or_id(
|
||||
self.dhcp_profile)
|
||||
self._native_dhcp_profile_uuid = dhcp_id
|
||||
else:
|
||||
self._native_dhcp_profile_uuid = None
|
||||
|
||||
def _translate_metadata_proxy(self, nsxlib, search_scope=None):
|
||||
if self.metadata_proxy:
|
||||
proxy_id = None
|
||||
if search_scope:
|
||||
# Find the TZ by its tag
|
||||
proxy_id = nsxlib.get_id_by_resource_and_tag(
|
||||
nsxlib.native_md_proxy.resource_type,
|
||||
search_scope,
|
||||
self.metadata_proxy)
|
||||
if not proxy_id:
|
||||
proxy_id = nsxlib.native_md_proxy.get_id_by_name_or_id(
|
||||
self.metadata_proxy)
|
||||
self._native_md_proxy_uuid = proxy_id
|
||||
else:
|
||||
self._native_md_proxy_uuid = None
|
||||
|
||||
def translate_configured_names_to_uuids(self, nsxlib):
|
||||
# May be overriden by children
|
||||
# Default implementation assumes UUID is provided in config
|
||||
# TODO(annak): refine this when we have a better picture
|
||||
# what az config is relevant for policy
|
||||
self._native_dhcp_profile_uuid = self.dhcp_profile
|
||||
self._native_md_proxy_uuid = self.metadata_proxy
|
||||
self._default_overlay_tz_uuid = self.default_overlay_tz
|
||||
self._default_vlan_tz_uuid = self.default_vlan_tz
|
||||
self._default_tier0_router = self.default_tier0_router
|
||||
self._native_dhcp_profile_uuid = self.dhcp_profile
|
||||
self._native_md_proxy_uuid = self.metadata_proxy
|
||||
|
|
|
@ -69,6 +69,7 @@ from vmware_nsx.db import extended_security_group as extended_sec
|
|||
from vmware_nsx.db import extended_security_group_rule as extend_sg_rule
|
||||
from vmware_nsx.db import maclearning as mac_db
|
||||
from vmware_nsx.db import nsx_portbindings_db as pbin_db
|
||||
from vmware_nsx.extensions import advancedserviceproviders as as_providers
|
||||
from vmware_nsx.extensions import maclearning as mac_ext
|
||||
from vmware_nsx.extensions import providersecuritygroup as provider_sg
|
||||
from vmware_nsx.extensions import secgroup_rule_local_ip_prefix as sg_prefix
|
||||
|
@ -149,6 +150,19 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||
webob.exc.HTTPBadRequest,
|
||||
})
|
||||
|
||||
def _init_native_metadata(self):
|
||||
if not self.nsxlib:
|
||||
return
|
||||
|
||||
try:
|
||||
for az in self.get_azs_list():
|
||||
self.nsxlib.native_md_proxy.get(az._native_md_proxy_uuid)
|
||||
except nsx_lib_exc.ManagerError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Unable to retrieve Metadata Proxy %s, "
|
||||
"native metadata service is not supported",
|
||||
az._native_md_proxy_uuid)
|
||||
|
||||
def _get_conf_attr(self, attr):
|
||||
plugin_cfg = getattr(cfg.CONF, self.cfg_group)
|
||||
return getattr(plugin_cfg, attr)
|
||||
|
@ -1515,6 +1529,26 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||
context, created_subnet['id'])
|
||||
return created_subnet
|
||||
|
||||
def _get_neutron_net_ids_by_nsx_id(self, context, nsx_id):
|
||||
"""Should be implemented by each plugin"""
|
||||
pass
|
||||
|
||||
def get_subnets(self, context, filters=None, fields=None, sorts=None,
|
||||
limit=None, marker=None, page_reverse=False):
|
||||
filters = filters or {}
|
||||
lswitch_ids = filters.pop(as_providers.ADV_SERVICE_PROVIDERS, [])
|
||||
if lswitch_ids:
|
||||
# This is a request from Nova for metadata processing.
|
||||
# Find the corresponding neutron network for each logical switch.
|
||||
network_ids = filters.pop('network_id', [])
|
||||
context = context.elevated()
|
||||
for lswitch_id in lswitch_ids:
|
||||
network_ids += self._get_neutron_net_ids_by_nsx_id(
|
||||
context, lswitch_id)
|
||||
filters['network_id'] = network_ids
|
||||
return super(NsxPluginV3Base, self).get_subnets(
|
||||
context, filters, fields, sorts, limit, marker, page_reverse)
|
||||
|
||||
def delete_subnet(self, context, subnet_id):
|
||||
# TODO(berlin): cancel public external subnet announcement
|
||||
if self._has_native_dhcp_metadata():
|
||||
|
@ -1542,6 +1576,11 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||
def _is_vlan_router_interface_supported(self):
|
||||
"""Should be implemented by each plugin"""
|
||||
|
||||
def _is_ddi_supported_on_network(self, context, network_id):
|
||||
result, _ = self._is_ddi_supported_on_net_with_type(
|
||||
context, network_id)
|
||||
return result
|
||||
|
||||
def _is_ddi_supported_on_net_with_type(self, context, network_id):
|
||||
net = self.get_network(context, network_id)
|
||||
# NSX current does not support transparent VLAN ports for
|
||||
|
@ -1641,3 +1680,39 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||
'addr_scope': gw_address_scope})
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_mdproxy_port_name(self, net_name, net_id):
|
||||
return utils.get_name_and_uuid('%s-%s' % ('mdproxy',
|
||||
net_name or 'network'),
|
||||
net_id)
|
||||
|
||||
def _create_net_mdproxy_port(self, context, network, az, nsx_net_id):
|
||||
if (not self.nsxlib or
|
||||
not self._has_native_dhcp_metadata()):
|
||||
return
|
||||
is_ddi_network = self._is_ddi_supported_on_network(
|
||||
context, network['id'])
|
||||
if is_ddi_network:
|
||||
# Enable native metadata proxy for this network.
|
||||
tags = self.nsxlib.build_v3_tags_payload(
|
||||
network, resource_type='os-neutron-net-id',
|
||||
project_name=context.tenant_name)
|
||||
name = self._get_mdproxy_port_name(network['name'],
|
||||
network['id'])
|
||||
md_port = self.nsxlib.logical_port.create(
|
||||
nsx_net_id, az._native_md_proxy_uuid,
|
||||
tags=tags, name=name,
|
||||
attachment_type=nsxlib_consts.ATTACHMENT_MDPROXY)
|
||||
LOG.debug("Created MD-Proxy logical port %(port)s "
|
||||
"for network %(network)s",
|
||||
{'port': md_port['id'],
|
||||
'network': network['id']})
|
||||
|
||||
def _delete_nsx_port_by_network(self, network_id):
|
||||
if not self.nsxlib:
|
||||
return
|
||||
port_id = self.nsxlib.get_id_by_resource_and_tag(
|
||||
self.nsxlib.logical_port.resource_type,
|
||||
'os-neutron-net-id', network_id)
|
||||
if port_id:
|
||||
self.nsxlib.logical_port.delete(port_id)
|
||||
|
|
|
@ -93,11 +93,10 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||
'az': self.name})
|
||||
raise nsx_exc.NsxPluginException(err_msg=msg)
|
||||
|
||||
def translate_configured_names_to_uuids(self, nsxpolicy):
|
||||
def translate_configured_names_to_uuids(self, nsxpolicy, nsxlib=None):
|
||||
super(NsxPAvailabilityZone, self).translate_configured_names_to_uuids(
|
||||
nsxpolicy)
|
||||
|
||||
# TODO(asarfaty): add DHCP/metadata parameters
|
||||
# TODO(asarfaty): add support for init_objects_by_tags
|
||||
self._default_overlay_tz_uuid = self._init_default_resource(
|
||||
nsxpolicy.transport_zone, 'default_overlay_tz',
|
||||
|
@ -117,6 +116,14 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||
|
||||
self.dhcp_relay_service = cfg.CONF.nsx_p.dhcp_relay_service
|
||||
|
||||
# If passthrough api is supported, also initialize those NSX objects
|
||||
if nsxlib:
|
||||
self._translate_dhcp_profile(nsxlib)
|
||||
self._translate_metadata_proxy(nsxlib)
|
||||
else:
|
||||
self._native_dhcp_profile_uuid = None
|
||||
self._native_md_proxy_uuid = None
|
||||
|
||||
|
||||
class NsxPAvailabilityZones(common_az.ConfiguredAvailabilityZones):
|
||||
|
||||
|
|
|
@ -173,10 +173,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
self._prepare_default_rules()
|
||||
self._init_segment_profiles()
|
||||
|
||||
for az in self.get_azs_list():
|
||||
az.translate_configured_names_to_uuids(self.nsxpolicy)
|
||||
|
||||
self._init_native_dhcp()
|
||||
self._init_dhcp_metadata()
|
||||
|
||||
# Init QoS
|
||||
qos_driver.register(qos_utils.PolicyQosNotificationsHandler())
|
||||
|
@ -189,9 +186,30 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
|
||||
def _init_default_config(self):
|
||||
# Default tier0/transport zones are initialized via the default AZ
|
||||
|
||||
# Validate other mandatory configuration
|
||||
if cfg.CONF.nsx_p.allow_passthrough:
|
||||
if not cfg.CONF.nsx_p.dhcp_profile:
|
||||
raise cfg.RequiredOptError("dhcp_profile",
|
||||
group=cfg.OptGroup('nsx_p'))
|
||||
|
||||
if not cfg.CONF.nsx_p.metadata_proxy:
|
||||
raise cfg.RequiredOptError("metadata_proxy",
|
||||
group=cfg.OptGroup('nsx_p'))
|
||||
|
||||
# Init AZ resources
|
||||
for az in self.get_azs_list():
|
||||
az.translate_configured_names_to_uuids(self.nsxpolicy)
|
||||
az.translate_configured_names_to_uuids(
|
||||
self.nsxpolicy, nsxlib=self.nsxlib)
|
||||
|
||||
def _init_dhcp_metadata(self):
|
||||
if (cfg.CONF.dhcp_agent_notification and
|
||||
cfg.CONF.nsx_p.allow_passthrough):
|
||||
msg = _("Need to disable dhcp_agent_notification when "
|
||||
"native DHCP & Metadata is enabled")
|
||||
raise nsx_exc.NsxPluginException(err_msg=msg)
|
||||
self._init_native_dhcp()
|
||||
self._init_native_metadata()
|
||||
|
||||
def init_availability_zones(self):
|
||||
self._availability_zones_data = nsxp_az.NsxPAvailabilityZones()
|
||||
|
@ -389,8 +407,9 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
# Create network in Neutron
|
||||
created_net = super(NsxPolicyPlugin, self).create_network(
|
||||
context, network)
|
||||
super(NsxPolicyPlugin, self).update_network(context,
|
||||
created_net['id'],
|
||||
net_id = created_net['id']
|
||||
super(NsxPolicyPlugin, self).update_network(
|
||||
context, net_id,
|
||||
{'network': {'vlan_transparent': vlt}})
|
||||
self._extension_manager.process_create_network(
|
||||
context, net_data, created_net)
|
||||
|
@ -399,12 +418,12 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
self._process_network_port_security_create(
|
||||
context, net_data, created_net)
|
||||
self._process_l3_create(context, created_net, net_data)
|
||||
self._add_az_to_net(context, created_net['id'], net_data)
|
||||
self._add_az_to_net(context, net_id, net_data)
|
||||
|
||||
if provider_data['is_provider_net']:
|
||||
# Save provider network fields, needed by get_network()
|
||||
net_bindings = [nsx_db.add_network_binding(
|
||||
context.session, created_net['id'],
|
||||
context.session, net_id,
|
||||
provider_data['net_type'],
|
||||
provider_data['physical_net'],
|
||||
provider_data['vlan_id'])]
|
||||
|
@ -420,11 +439,21 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
LOG.exception("Failed to create NSX network network: %s", e)
|
||||
with excutils.save_and_reraise_exception():
|
||||
super(NsxPolicyPlugin, self).delete_network(
|
||||
context, created_net['id'])
|
||||
context, net_id)
|
||||
|
||||
# MD Proxy is currently supported by the passthrough api only
|
||||
if is_backend_network and cfg.CONF.nsx_p.allow_passthrough:
|
||||
try:
|
||||
nsx_net_id = self._get_network_nsx_id(context, net_id)
|
||||
self._create_net_mdproxy_port(
|
||||
context, created_net, az, nsx_net_id)
|
||||
except Exception as e:
|
||||
LOG.error("Failed to create mdproxy port for network %s: %s",
|
||||
net_id, e)
|
||||
|
||||
# this extra lookup is necessary to get the
|
||||
# latest db model for the extension functions
|
||||
net_model = self._get_network(context, created_net['id'])
|
||||
net_model = self._get_network(context, net_id)
|
||||
resource_extend.apply_funcs('networks', created_net, net_model)
|
||||
|
||||
# Update the QoS policy (will affect only future compute ports)
|
||||
|
@ -445,11 +474,15 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
self._process_l3_delete(context, network_id)
|
||||
super(NsxPolicyPlugin, self).delete_network(
|
||||
context, network_id)
|
||||
|
||||
# MD Proxy is currently supported by the passthrough api only.
|
||||
# Use it to delete mdproxy ports
|
||||
if not is_external_net and cfg.CONF.nsx_p.allow_passthrough:
|
||||
self._delete_nsx_port_by_network(network_id)
|
||||
|
||||
# Delete the network segment from the backend
|
||||
if not is_external_net and not is_nsx_net:
|
||||
self.nsxpolicy.segment.delete(network_id)
|
||||
else:
|
||||
# TODO(asarfaty): for NSX network we may need to delete DHCP conf
|
||||
pass
|
||||
|
||||
def update_network(self, context, network_id, network):
|
||||
original_net = super(NsxPolicyPlugin, self).get_network(
|
||||
|
@ -1917,3 +1950,6 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||
|
||||
def _is_vlan_router_interface_supported(self):
|
||||
return True
|
||||
|
||||
def _get_neutron_net_ids_by_nsx_id(self, context, lswitch_id):
|
||||
return [lswitch_id]
|
||||
|
|
|
@ -76,35 +76,6 @@ class NsxV3AvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||
self._edge_cluster_uuid = edge_cluster_uuid
|
||||
else:
|
||||
self._edge_cluster_uuid = None
|
||||
if self.dhcp_profile:
|
||||
dhcp_id = None
|
||||
if search_scope:
|
||||
# Find the TZ by its tag
|
||||
dhcp_id = nsxlib.get_id_by_resource_and_tag(
|
||||
nsxlib.native_dhcp_profile.resource_type,
|
||||
search_scope,
|
||||
self.dhcp_profile)
|
||||
if not dhcp_id:
|
||||
dhcp_id = nsxlib.native_dhcp_profile.get_id_by_name_or_id(
|
||||
self.dhcp_profile)
|
||||
self._native_dhcp_profile_uuid = dhcp_id
|
||||
else:
|
||||
self._native_dhcp_profile_uuid = None
|
||||
|
||||
if self.metadata_proxy:
|
||||
proxy_id = None
|
||||
if search_scope:
|
||||
# Find the TZ by its tag
|
||||
proxy_id = nsxlib.get_id_by_resource_and_tag(
|
||||
nsxlib.native_md_proxy.resource_type,
|
||||
search_scope,
|
||||
self.metadata_proxy)
|
||||
if not proxy_id:
|
||||
proxy_id = nsxlib.native_md_proxy.get_id_by_name_or_id(
|
||||
self.metadata_proxy)
|
||||
self._native_md_proxy_uuid = proxy_id
|
||||
else:
|
||||
self._native_md_proxy_uuid = None
|
||||
|
||||
if self.default_overlay_tz:
|
||||
tz_id = None
|
||||
|
@ -124,6 +95,9 @@ class NsxV3AvailabilityZone(v3_az.NsxV3AvailabilityZone):
|
|||
else:
|
||||
self._default_overlay_tz_uuid = None
|
||||
|
||||
self._translate_dhcp_profile(nsxlib, search_scope=search_scope)
|
||||
self._translate_metadata_proxy(nsxlib, search_scope=search_scope)
|
||||
|
||||
# Optional configurations (may be None)
|
||||
if self.default_vlan_tz:
|
||||
tz_id = None
|
||||
|
|
|
@ -74,7 +74,6 @@ from vmware_nsx.common import nsx_constants
|
|||
from vmware_nsx.common import utils
|
||||
from vmware_nsx.db import db as nsx_db
|
||||
from vmware_nsx.dhcp_meta import rpc as nsx_rpc
|
||||
from vmware_nsx.extensions import advancedserviceproviders as as_providers
|
||||
from vmware_nsx.extensions import housekeeper as hk_ext
|
||||
from vmware_nsx.extensions import maclearning as mac_ext
|
||||
from vmware_nsx.extensions import projectpluginmap
|
||||
|
@ -557,8 +556,11 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
group=cfg.OptGroup('nsx_v3'))
|
||||
|
||||
# Translate all the uuids in each of the availability
|
||||
search_scope = (cfg.CONF.nsx_v3.search_objects_scope
|
||||
if cfg.CONF.nsx_v3.init_objects_by_tags else None)
|
||||
for az in self.get_azs_list():
|
||||
az.translate_configured_names_to_uuids(self.nsxlib)
|
||||
az.translate_configured_names_to_uuids(
|
||||
self.nsxlib, search_scope=search_scope)
|
||||
|
||||
@nsxlib_utils.retry_upon_exception(
|
||||
Exception, max_attempts=cfg.CONF.nsx_v3.retries)
|
||||
|
@ -763,27 +765,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
self._setup_dhcp()
|
||||
self._start_rpc_notifiers()
|
||||
|
||||
def _init_native_dhcp(self):
|
||||
try:
|
||||
for az in self.get_azs_list():
|
||||
self.nsxlib.native_dhcp_profile.get(
|
||||
az._native_dhcp_profile_uuid)
|
||||
except nsx_lib_exc.ManagerError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Unable to retrieve DHCP Profile %s, "
|
||||
"native DHCP service is not supported",
|
||||
az._native_dhcp_profile_uuid)
|
||||
|
||||
def _init_native_metadata(self):
|
||||
try:
|
||||
for az in self.get_azs_list():
|
||||
self.nsxlib.native_md_proxy.get(az._native_md_proxy_uuid)
|
||||
except nsx_lib_exc.ManagerError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Unable to retrieve Metadata Proxy %s, "
|
||||
"native metadata service is not supported",
|
||||
az._native_md_proxy_uuid)
|
||||
|
||||
def _setup_rpc(self):
|
||||
self.endpoints = [dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback(),
|
||||
|
@ -791,6 +772,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
|
||||
def _setup_dhcp(self):
|
||||
"""Initialize components to support DHCP."""
|
||||
#TODO(asarfaty): move to common code and use in policy plugin too
|
||||
self.network_scheduler = importutils.import_object(
|
||||
cfg.CONF.network_scheduler_driver
|
||||
)
|
||||
|
@ -883,11 +865,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
provider_data['vlan_id'],
|
||||
nsx_id)
|
||||
|
||||
def _is_ddi_supported_on_network(self, context, network_id):
|
||||
result, _ = self._is_ddi_supported_on_net_with_type(
|
||||
context, network_id)
|
||||
return result
|
||||
|
||||
def _is_vlan_router_interface_supported(self):
|
||||
return self.nsxlib.feature_supported(
|
||||
nsxlib_consts.FEATURE_VLAN_ROUTER_INTERFACE)
|
||||
|
@ -932,26 +909,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
self.nsxlib.transport_zone.TRANSPORT_TYPE_OVERLAY)
|
||||
return False
|
||||
|
||||
def get_subnets(self, context, filters=None, fields=None, sorts=None,
|
||||
limit=None, marker=None, page_reverse=False):
|
||||
filters = filters or {}
|
||||
lswitch_ids = filters.pop(as_providers.ADV_SERVICE_PROVIDERS, [])
|
||||
if lswitch_ids:
|
||||
# This is a request from Nova for metadata processing.
|
||||
# Find the corresponding neutron network for each logical switch.
|
||||
network_ids = filters.pop('network_id', [])
|
||||
context = context.elevated()
|
||||
for lswitch_id in lswitch_ids:
|
||||
network_ids += nsx_db.get_net_ids(context.session, lswitch_id)
|
||||
filters['network_id'] = network_ids
|
||||
return super(NsxV3Plugin, self).get_subnets(
|
||||
context, filters, fields, sorts, limit, marker, page_reverse)
|
||||
|
||||
def _get_mdproxy_port_name(self, net_name, net_id):
|
||||
return utils.get_name_and_uuid('%s-%s' % ('mdproxy',
|
||||
net_name or 'network'),
|
||||
net_id)
|
||||
|
||||
def _tier0_validator(self, tier0_uuid):
|
||||
self.nsxlib.router.validate_tier0(self.tier0_groups_dict, tier0_uuid)
|
||||
|
||||
|
@ -1027,26 +984,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
{'network': {'vlan_transparent': vlt}})
|
||||
|
||||
rollback_network = True
|
||||
if is_backend_network:
|
||||
self._create_net_mdproxy_port(
|
||||
context, created_net, az, nsx_net_id)
|
||||
|
||||
is_ddi_network = self._is_ddi_supported_on_network(
|
||||
context, created_net['id'])
|
||||
if (is_backend_network and
|
||||
cfg.CONF.nsx_v3.native_dhcp_metadata and
|
||||
is_ddi_network):
|
||||
# Enable native metadata proxy for this network.
|
||||
tags = self.nsxlib.build_v3_tags_payload(
|
||||
created_net, resource_type='os-neutron-net-id',
|
||||
project_name=context.tenant_name)
|
||||
name = self._get_mdproxy_port_name(created_net['name'],
|
||||
created_net['id'])
|
||||
md_port = self.nsxlib.logical_port.create(
|
||||
nsx_net_id, az._native_md_proxy_uuid,
|
||||
tags=tags, name=name,
|
||||
attachment_type=nsxlib_consts.ATTACHMENT_MDPROXY)
|
||||
LOG.debug("Created MD-Proxy logical port %(port)s "
|
||||
"for network %(network)s",
|
||||
{'port': md_port['id'],
|
||||
'network': created_net['id']})
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
# Undo creation on the backend
|
||||
|
@ -1057,7 +998,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
if (cfg.CONF.nsx_v3.native_dhcp_metadata and
|
||||
is_backend_network and is_ddi_network):
|
||||
# Delete the mdproxy port manually
|
||||
self._delete_network_nsx_dhcp_port(created_net['id'])
|
||||
self._delete_nsx_port_by_network(created_net['id'])
|
||||
|
||||
if rollback_network:
|
||||
super(NsxV3Plugin, self).delete_network(
|
||||
|
@ -1144,13 +1085,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
# we have nothing else to do but raise the exception.
|
||||
raise
|
||||
|
||||
def _delete_network_nsx_dhcp_port(self, network_id):
|
||||
port_id = self.nsxlib.get_id_by_resource_and_tag(
|
||||
self.nsxlib.logical_port.resource_type,
|
||||
'os-neutron-net-id', network_id)
|
||||
if port_id:
|
||||
self.nsxlib.logical_port.delete(port_id)
|
||||
|
||||
def delete_network(self, context, network_id):
|
||||
if cfg.CONF.nsx_v3.native_dhcp_metadata:
|
||||
lock = 'nsxv3_network_' + network_id
|
||||
|
@ -1176,7 +1110,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
if (cfg.CONF.nsx_v3.native_dhcp_metadata and is_nsx_net and
|
||||
is_ddi_network):
|
||||
# Delete the mdproxy port manually
|
||||
self._delete_network_nsx_dhcp_port(network_id)
|
||||
self._delete_nsx_port_by_network(network_id)
|
||||
# TODO(berlin): delete subnets public announce on the network
|
||||
|
||||
def _get_network_nsx_id(self, context, neutron_id):
|
||||
|
@ -1897,6 +1831,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
return ips
|
||||
|
||||
def _add_dhcp_binding(self, context, port):
|
||||
#TODO(asarfaty): move to common code and use in policy plugin too
|
||||
if not utils.is_port_dhcp_configurable(port):
|
||||
return
|
||||
dhcp_service = nsx_db.get_nsx_service_binding(
|
||||
|
@ -1946,6 +1881,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
|
||||
def _get_dhcp_options(self, context, ip, extra_dhcp_opts, net_id,
|
||||
subnet):
|
||||
#TODO(asarfaty): move to common code and use in policy plugin too
|
||||
# Always add option121.
|
||||
net_az = self.get_network_az_by_net_id(context, net_id)
|
||||
options = {'option121': {'static_routes': [
|
||||
|
@ -1983,6 +1919,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
|
||||
def _add_dhcp_binding_on_server(self, context, dhcp_service_id, subnet_id,
|
||||
ip, port):
|
||||
#TODO(asarfaty): move to common code and use in policy plugin too
|
||||
try:
|
||||
hostname = 'host-%s' % ip.replace('.', '-')
|
||||
subnet = self.get_subnet(context, subnet_id)
|
||||
|
@ -4129,3 +4066,6 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||
|
||||
def _get_tier0_uplink_ips(self, tier0_id):
|
||||
return self.nsxlib.logical_router_port.get_tier0_uplink_ips(tier0_id)
|
||||
|
||||
def _get_neutron_net_ids_by_nsx_id(self, context, lswitch_id):
|
||||
return nsx_db.get_net_ids(context.session, lswitch_id)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -60,6 +60,7 @@ NSX_OVERLAY_TZ_NAME = 'OVERLAY_TZ'
|
|||
NSX_VLAN_TZ_NAME = 'VLAN_TZ'
|
||||
DEFAULT_TIER0_ROUTER_UUID = "efad0078-9204-4b46-a2d8-d4dd31ed448f"
|
||||
NSX_DHCP_PROFILE_ID = 'DHCP_PROFILE'
|
||||
NSX_MD_PROXY_ID = 'MD_PROXY'
|
||||
LOGICAL_SWITCH_ID = '00000000-1111-2222-3333-444444444444'
|
||||
|
||||
|
||||
|
@ -148,11 +149,16 @@ class NsxPPluginTestCaseMixin(
|
|||
"vmware_nsxlib.v3.resources.LogicalDhcpServer.create_binding",
|
||||
side_effect=_return_id_key).start()
|
||||
|
||||
mock.patch("vmware_nsxlib.v3.NsxLib."
|
||||
"get_id_by_resource_and_tag").start()
|
||||
|
||||
def setup_conf_overrides(self):
|
||||
cfg.CONF.set_override('default_overlay_tz', NSX_OVERLAY_TZ_NAME,
|
||||
'nsx_p')
|
||||
cfg.CONF.set_override('default_vlan_tz', NSX_VLAN_TZ_NAME, 'nsx_p')
|
||||
cfg.CONF.set_override('dhcp_profile', NSX_DHCP_PROFILE_ID, 'nsx_p')
|
||||
cfg.CONF.set_override('metadata_proxy', NSX_MD_PROXY_ID, 'nsx_p')
|
||||
cfg.CONF.set_override('dhcp_agent_notification', False)
|
||||
|
||||
def _create_network(self, fmt, name, admin_state_up,
|
||||
arg_list=None, providernet_args=None,
|
||||
|
@ -194,6 +200,10 @@ class NsxPPluginTestCaseMixin(
|
|||
arg_list=(pnet.NETWORK_TYPE,
|
||||
pnet.PHYSICAL_NETWORK))
|
||||
|
||||
def _initialize_azs(self):
|
||||
self.plugin.init_availability_zones()
|
||||
self.plugin._init_default_config()
|
||||
|
||||
|
||||
class NsxPTestNetworks(test_db_base_plugin_v2.TestNetworksV2,
|
||||
NsxPPluginTestCaseMixin):
|
||||
|
|
Loading…
Reference in New Issue