Delete device when instance_id is null

When nfv delete action is performed, it helps to
remove the device from tacker when that device's
instance_id is null.

Closes-bug: #1588713
(cherry picked from commit c74cb38f23)

Change-Id: I3796a1c5b4a077d14c56ff84976e72a5a891fdca
This commit is contained in:
Kanagaraj Manickam 2016-06-02 22:25:47 +05:30
parent 04a973be4e
commit 2e316342a0
1 changed files with 25 additions and 16 deletions

View File

@ -340,17 +340,23 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
driver_name = self._infra_driver_name(device_dict)
instance_id = self._instance_id(device_dict)
e = None
placement_attr = device_dict['placement_attr']
region_name = placement_attr.get('region_name', None)
try:
self._device_manager.invoke(
driver_name, 'delete_wait', plugin=self,
context=context, device_id=instance_id, auth_attr=auth_attr,
region_name=region_name)
except Exception as e_:
e = e_
device_dict['status'] = constants.ERROR
LOG.exception(_('_delete_device_wait'))
if instance_id:
placement_attr = device_dict['placement_attr']
region_name = placement_attr.get('region_name')
try:
self._device_manager.invoke(
driver_name,
'delete_wait',
plugin=self,
context=context,
device_id=instance_id,
auth_attr=auth_attr,
region_name=region_name)
except Exception as e_:
e = e_
device_dict['status'] = constants.ERROR
LOG.exception(_('_delete_device_wait'))
self.mgmt_delete_post(context, device_dict)
device_id = device_dict['id']
self._delete_device_post(context, device_id, e)
@ -370,11 +376,14 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
try:
self.mgmt_delete_pre(context, device_dict)
self.mgmt_call(context, device_dict, kwargs)
self._device_manager.invoke(driver_name, 'delete', plugin=self,
context=context,
device_id=instance_id,
auth_attr=vim_auth,
region_name=region_name)
if instance_id:
self._device_manager.invoke(driver_name,
'delete',
plugin=self,
context=context,
device_id=instance_id,
auth_attr=vim_auth,
region_name=region_name)
except Exception as e:
# TODO(yamahata): when the devaice is already deleted. mask
# the error, and delete row in db