Merge "NSXv: Adding more rotuer driver notifications"

This commit is contained in:
Jenkins 2017-04-15 12:27:56 +00:00 committed by Gerrit Code Review
commit c8551e32aa
2 changed files with 16 additions and 13 deletions

View File

@ -78,6 +78,8 @@ class RouterExclusiveDriver(router_driver.RouterBaseDriver):
def detach_router(self, context, router_id, router): def detach_router(self, context, router_id, router):
LOG.debug("Detach exclusive router id %s", router_id) LOG.debug("Detach exclusive router id %s", router_id)
router_db = self.plugin._get_router(context, router_id)
self._notify_before_router_edge_association(context, router_db)
self.edge_manager.unbind_router_on_edge(context, router_id) self.edge_manager.unbind_router_on_edge(context, router_id)
if self.plugin.metadata_proxy_handler: if self.plugin.metadata_proxy_handler:
az = self.get_router_az_by_id(context, router_id) az = self.get_router_az_by_id(context, router_id)
@ -195,7 +197,7 @@ class RouterExclusiveDriver(router_driver.RouterBaseDriver):
# Update static routes in all. # Update static routes in all.
self.plugin._update_routes(context, router_id, newnexthop) self.plugin._update_routes(context, router_id, newnexthop)
if new_ext_net_id: if new_ext_net_id or force_update:
self._notify_after_router_edge_association(context, router) self._notify_after_router_edge_association(context, router)
def add_router_interface(self, context, router_id, interface_info): def add_router_interface(self, context, router_id, interface_info):

View File

@ -95,6 +95,8 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
if not edge_id: if not edge_id:
return return
router_db = self.plugin._get_router(context, router_id)
self._notify_before_router_edge_association(context, router_db)
with locking.LockManager.get_lock(str(edge_id)): with locking.LockManager.get_lock(str(edge_id)):
self._remove_router_services_on_edge(context, router_id) self._remove_router_services_on_edge(context, router_id)
self._unbind_router_on_edge(context, router_id) self._unbind_router_on_edge(context, router_id)
@ -108,6 +110,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
LOG.debug("Shared router %s attached to edge %s", router_id, edge_id) LOG.debug("Shared router %s attached to edge %s", router_id, edge_id)
with locking.LockManager.get_lock(str(edge_id)): with locking.LockManager.get_lock(str(edge_id)):
self._add_router_services_on_available_edge(context, router_id) self._add_router_services_on_available_edge(context, router_id)
self._notify_after_router_edge_association(context, router_db)
def delete_router(self, context, router_id): def delete_router(self, context, router_id):
# make sure that the router binding is cleaned up # make sure that the router binding is cleaned up
@ -850,23 +853,25 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
return info return info
def remove_router_interface(self, context, router_id, interface_info): def remove_router_interface(self, context, router_id, interface_info):
detach = False
edge_id = edge_utils.get_router_edge_id(context, router_id) edge_id = edge_utils.get_router_edge_id(context, router_id)
with locking.LockManager.get_lock('nsx-shared-router-pool'): with locking.LockManager.get_lock('nsx-shared-router-pool'):
info = super( info = super(
nsx_v.NsxVPluginV2, self.plugin).remove_router_interface( nsx_v.NsxVPluginV2, self.plugin).remove_router_interface(
context, router_id, interface_info) context, router_id, interface_info)
subnet = self.plugin.get_subnet(context, info['subnet_id'])
network_id = subnet['network_id']
ports = self.plugin._get_router_interface_ports_by_network(
context, router_id, network_id)
if not ports:
router = self.plugin._get_router(context, router_id)
self._notify_before_router_edge_association(context, router)
with locking.LockManager.get_lock(str(edge_id)): with locking.LockManager.get_lock(str(edge_id)):
subnet = self.plugin.get_subnet(context, info['subnet_id'])
network_id = subnet['network_id']
router_ids = self.edge_manager.get_routers_on_same_edge( router_ids = self.edge_manager.get_routers_on_same_edge(
context, router_id) context, router_id)
self._update_nat_rules_on_routers(context, router_id, self._update_nat_rules_on_routers(context, router_id,
router_ids) router_ids)
self._update_subnets_and_dnat_firewall_on_routers( self._update_subnets_and_dnat_firewall_on_routers(
context, router_id, router_ids, allow_external=True) context, router_id, router_ids, allow_external=True)
ports = self.plugin._get_router_interface_ports_by_network(
context, router_id, network_id)
if not ports: if not ports:
edge_utils.delete_interface(self.nsx_v, context, edge_utils.delete_interface(self.nsx_v, context,
router_id, network_id) router_id, network_id)
@ -874,7 +879,9 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
# router # router
if not self.plugin._get_internal_network_ids_by_router( if not self.plugin._get_internal_network_ids_by_router(
context, router_id): context, router_id):
detach = True self._remove_router_services_on_edge(context,
router_id)
self._unbind_router_on_edge(context, router_id)
else: else:
address_groups = self.plugin._get_address_groups( address_groups = self.plugin._get_address_groups(
context, router_id, network_id) context, router_id, network_id)
@ -882,12 +889,6 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
router_id, router_id,
network_id, network_id,
address_groups) address_groups)
if detach:
router = self.plugin._get_router(context, router_id)
self._notify_before_router_edge_association(context, router)
with locking.LockManager.get_lock(str(edge_id)):
self._remove_router_services_on_edge(context, router_id)
self._unbind_router_on_edge(context, router_id)
return info return info
def _update_edge_router(self, context, router_id): def _update_edge_router(self, context, router_id):