Fix DVR for NSX-mh

The switch to the community management layer mixin introduced
several bugs in the NSX-mh plugins.

This patch:
1) Stops creating centralized SNAT interfaces for NSX distributed
   routers. The NSX backend does not need those and they therefore
   only waste IPs and create confusion. This is done by providing
   an empty implementation for the relevant methods.
2) Does not query l3-agents when removing router interface. This
   is causing errors during interface removal and preventing router
   removal, as the NSX plugin does not use l3 agents at all.
   This patch provides an empty implementation for the relevant
   method thus preventing the DVR mixin from doing any sort of
   operations pertaining l3 agents.
3) It ensures DVR router interfaces are taken into account in the
   management of metadata network for routers.

Change-Id: I149307ff67e464e78ae393bb57c25bbee607ee4b
Closes-Bug: #1433550
Closes-Bug: #1433553
Closes-Bug: #1433554
This commit is contained in:
Salvatore Orlando 2015-03-18 04:58:25 -07:00
parent 8846deb229
commit e248f87867
2 changed files with 26 additions and 6 deletions

View File

@ -24,7 +24,6 @@ from neutron.api.v2 import attributes
from neutron.common import constants as const
from neutron.common import exceptions as ntn_exc
from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.neutron.plugins.vmware.api_client import exception as api_exc
@ -98,7 +97,7 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
return
ctx_elevated = context.elevated()
device_filter = {'device_id': [router_id],
'device_owner': [l3_db.DEVICE_OWNER_ROUTER_INTF]}
'device_owner': const.ROUTER_INTERFACE_OWNERS}
# Retrieve ports calling database plugin
ports = db_base_plugin_v2.NeutronDbPluginV2.get_ports(
plugin, ctx_elevated, filters=device_filter)

View File

@ -1675,6 +1675,26 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
{'subnet_id': subnet_id, 'router_id': router_id})
return router_iface_info
def get_l3_agents_hosting_routers(self, context, routers):
# This method is just a stub added because is required by the l3 dvr
# mixin. That's so much for a management layer which is plugin
# agnostic
return []
def create_snat_intf_ports_if_not_exists(self, context, router):
# VMware plugins do not need SNAT interface ports
return []
def add_csnat_router_interface_port(self, context, router, network_id,
subnet_id, do_pop=True):
# VMware plugins do not need SNAT interface ports
return
def delete_csnat_router_interface_ports(self, context, router,
subnet_id=None):
# VMware plugins do not need SNAT interface ports
return
def remove_router_interface(self, context, router_id, interface_info):
# The code below is duplicated from base class, but comes handy
# as we need to retrieve the router port id before removing the port
@ -1686,8 +1706,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
port = self._get_port(context, port_id)
if port.get('fixed_ips'):
subnet_id = port['fixed_ips'][0]['subnet_id']
if not (port['device_owner'] == l3_db.DEVICE_OWNER_ROUTER_INTF and
port['device_id'] == router_id):
if not (port['device_owner'] in constants.ROUTER_INTERFACE_OWNERS
and port['device_id'] == router_id):
raise l3.RouterInterfaceNotFound(router_id=router_id,
port_id=port_id)
elif 'subnet_id' in interface_info:
@ -1696,8 +1716,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
rport_qry = context.session.query(models_v2.Port)
ports = rport_qry.filter_by(
device_id=router_id,
device_owner=l3_db.DEVICE_OWNER_ROUTER_INTF,
network_id=subnet['network_id'])
network_id=subnet['network_id']).filter(
models_v2.Port.device_owner.in_(
constants.ROUTER_INTERFACE_OWNERS))
for p in ports:
if p['fixed_ips'][0]['subnet_id'] == subnet_id:
port_id = p['id']