response = self.client.post("/api/vnflcm/v1/vnf_instances/12/heal", data=req_data, format='json')\r
self.failUnlessEqual(status.HTTP_404_NOT_FOUND, response.status_code)\r
\r
+ def test_heal_vnf_conflict(self):\r
+ req_data = {}\r
+ NfInstModel(\r
+ nfinstid='1267',\r
+ nf_name='VNF1',\r
+ status='NOT_INSTANTIATED').save()\r
+ response = self.client.post("/api/vnflcm/v1/vnf_instances/1267/heal", data=req_data, format='json')\r
+ self.failUnlessEqual(status.HTTP_409_CONFLICT, response.status_code)\r
+ NfInstModel.objects.filter(nfinstid='1267').delete()\r
+\r
@mock.patch.object(HealVnf, 'run')\r
def test_heal_vnf_success(self, mock_run):\r
req_data = {}\r
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
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