NSXv - eliminate task use from delete_interface

Delete interface calls should be synchronous.

Change-Id: I78169ac54f7b3b21719f2477eea48b56e1b4a0ba
This commit is contained in:
Kobi Samoray 2016-07-27 16:00:47 +03:00
parent 1ef09c105c
commit 3d87436acb
3 changed files with 13 additions and 41 deletions

View File

@ -629,8 +629,7 @@ class RouterSharedDriver(router_driver.RouterBaseDriver):
if intf_net_id:
intf_net_ids.remove(intf_net_id)
for net_id in intf_net_ids:
edge_utils.delete_interface(self.nsx_v, context, router_id, net_id,
is_wait=False)
edge_utils.delete_interface(self.nsx_v, context, router_id, net_id)
def _update_router_gw_info(self, context, router_id, info,
is_routes_update=False,

View File

@ -358,39 +358,20 @@ class EdgeApplianceDriver(object):
# avoid bug 1389358
self.check_edge_jobs(edge_id)
def _delete_interface(self, task):
edge_id = task.userdata['edge_id']
vnic_index = task.userdata['vnic_index']
LOG.debug("start deleting vnic %s", vnic_index)
def delete_interface(self, router_id, edge_id, index, jobdata=None):
LOG.debug("Deleting vnic %(vnic_index)s: on edge %(edge_id)s",
{'vnic_index': index, 'edge_id': edge_id})
try:
self.vcns.delete_interface(edge_id, vnic_index)
self.vcns.delete_interface(edge_id, index)
except exceptions.VcnsApiException:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete vnic %(vnic_index)s: "
"on edge %(edge_id)s"),
{'vnic_index': vnic_index,
{'vnic_index': index,
'edge_id': edge_id})
except Exception:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to delete vnic %d"), vnic_index)
return task_constants.TaskStatus.COMPLETED
def delete_interface(self, router_id, edge_id, index, jobdata=None):
task_name = "delete-interface-%s-%d" % (edge_id, index)
userdata = {
'router_id': router_id,
'edge_id': edge_id,
'vnic_index': index,
'jobdata': jobdata
}
task = tasks.Task(task_name, router_id, self._delete_interface,
userdata=userdata)
task.add_result_monitor(self.callbacks.interface_delete_result)
self.task_manager.add(task)
# avoid bug 1389358
self.check_edge_jobs(edge_id)
return task
LOG.debug("Deletion complete vnic %(vnic_index)s: on edge %(edge_id)s",
{'vnic_index': index, 'edge_id': edge_id})
def _deploy_edge(self, task):
userdata = task.userdata

View File

@ -1524,9 +1524,7 @@ class EdgeManager(object):
plr_id, plr_edge_id, None, [])
task.wait(task_const.TaskState.RESULT)
# Delete internal vnic
task = self.nsxv_manager.delete_interface(
plr_id, plr_edge_id, plr_vnic_index)
task.wait(task_const.TaskState.RESULT)
self.nsxv_manager.delete_interface(plr_id, plr_edge_id, plr_vnic_index)
nsxv_db.free_edge_vnic_by_network(
context.session, plr_edge_id, lswitch_id)
# Delete the PLR
@ -2180,15 +2178,14 @@ def _update_vdr_internal_interface(nsxv_manager, context, router_id,
address_groups=address_groups, is_connected=is_connected)
def delete_interface(nsxv_manager, context, router_id, network_id,
dist=False, is_wait=True):
def delete_interface(nsxv_manager, context, router_id, network_id, dist=False):
with locking.LockManager.get_lock(str(router_id)):
_delete_interface(nsxv_manager, context, router_id, network_id,
dist=dist, is_wait=is_wait)
dist=dist)
def _delete_interface(nsxv_manager, context, router_id, network_id,
dist=False, is_wait=True):
dist=False):
# Get the pg/wire id of the network id
vcns_network_id = _retrieve_nsx_switch_id(context, network_id)
LOG.debug("Network id %(network_id)s corresponding ref is : "
@ -2212,10 +2209,8 @@ def _delete_interface(nsxv_manager, context, router_id, network_id,
'edge_id': edge_id})
return
if not dist:
task = nsxv_manager.delete_interface(
nsxv_manager.delete_interface(
router_id, edge_id, edge_vnic_binding.vnic_index)
if is_wait:
task.wait(task_const.TaskState.RESULT)
nsxv_db.free_edge_vnic_by_network(
context.session, edge_id, network_id)
else:
@ -2415,9 +2410,6 @@ class NsxVCallbacks(object):
def interface_update_result(self, task):
LOG.debug("interface_update_result %d", task.status)
def interface_delete_result(self, task):
LOG.debug("interface_delete_result %d", task.status)
def snat_create_result(self, task):
LOG.debug("snat_create_result %d", task.status)