Add ut cases for heal vnf
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / views / heal_vnf_view.py
index 4fe3f84..24b33e3 100644 (file)
@@ -22,7 +22,9 @@ from rest_framework.views import APIView
 from lcm.nf.biz.heal_vnf import HealVnf\r
 from lcm.nf.serializers.heal_vnf_req import HealVnfRequestSerializer\r
 from lcm.nf.serializers.response import ProblemDetailsSerializer\r
-from lcm.pub.exceptions import NFLCMException, NFLCMExceptionNotFound\r
+from lcm.pub.exceptions import NFLCMException\r
+from lcm.pub.exceptions import NFLCMExceptionNotFound\r
+from lcm.pub.exceptions import NFLCMExceptionConflict\r
 from lcm.pub.utils.jobutil import JobUtil\r
 from lcm.pub.database.models import NfInstModel\r
 from lcm.nf.const import VNF_STATUS\r
@@ -63,6 +65,9 @@ class HealVnfView(APIView):
         if not vnf_insts.exists():\r
             raise NFLCMExceptionNotFound("VNF nf_inst_id does not exist.")\r
 \r
+        if vnf_insts[0].status != 'INSTANTIATED':\r
+            raise NFLCMExceptionConflict("VNF instantiationState is not INSTANTIATED.")\r
+\r
         NfInstModel.objects.filter(nfinstid=nf_inst_id).update(status=VNF_STATUS.HEALING)\r
         JobUtil.add_job_status(job_id, 15, 'Nf healing pre-check finish')\r
         logger.info("Nf healing pre-check finish")\r