Fix bug of delete vnfs
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / vnfs / vnf_cancel / delete_vnf_identifier.py
index c3772a2..c2afe07 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 import logging
 
-from lcm.pub.database.models import NfInstModel
+from lcm.pub.database.models import NfInstModel, NfvoRegInfoModel
 from lcm.pub.exceptions import NFLCMException
 
 logger = logging.getLogger(__name__)
@@ -27,8 +27,10 @@ class DeleteVnf:
     def do_biz(self):
         vnf_insts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
         if not vnf_insts.exists():
-            raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id)
-        sel_vnf = vnf_insts[0]
-        if sel_vnf.status != 'NOT_INSTANTIATED':
-            raise NFLCMException("Don't allow to delete vnf(status:[%s])" % sel_vnf.status)
+            logger.warn('VnfInst(%s) does not exist' % self.nf_inst_id)
+            return
+        #sel_vnf = vnf_insts[0]
+        #if sel_vnf.status != 'NOT_INSTANTIATED':
+        #    raise NFLCMException("Don't allow to delete vnf(status:[%s])" % sel_vnf.status)
         NfInstModel.objects.filter(nfinstid=self.nf_inst_id).delete()
+        NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id).delete()