Correct error handling for PENDING_DELETE VNFs.

Partial-Bug: #1775373

Change-Id: I82e3dc0531c1b9e702fe41d0dcf244dc514c53ac
This commit is contained in:
dharmendra 2018-07-10 08:50:15 +00:00
parent 621d6488ca
commit a7ba6d02aa
3 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Correct error handling for PENDING_DELETE VNFs.

View File

@ -482,8 +482,14 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
with_lockmode('update').one())
except orm_exc.NoResultFound:
raise vnfm.VNFNotFound(vnf_id=vnf_id)
if vnf_db.status == constants.PENDING_DELETE:
error_reason = _("Operation on PENDING_DELETE VNF "
"is not permited. Please contact your "
"Administrator.")
raise vnfm.VNFDeleteFailed(reason=error_reason)
if vnf_db.status == constants.PENDING_UPDATE:
raise vnfm.VNFInUse(vnf_id=vnf_id)
# TODO(dkushwaha): status check/update will be moved out from here.
vnf_db.update({'status': new_status})
return vnf_db

View File

@ -75,6 +75,10 @@ class VNFDeleteWaitFailed(exceptions.TackerException):
message = _('%(reason)s')
class VNFDeleteFailed(exceptions.TackerException):
message = _('%(reason)s')
class VNFDNotFound(exceptions.NotFound):
message = _('VNFD %(vnfd_id)s could not be found')