Add precheck to inst vnf 87/84987/1
authorfujinhua <fu.jinhua@zte.com.cn>
Thu, 11 Apr 2019 02:30:49 +0000 (10:30 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Thu, 11 Apr 2019 02:30:49 +0000 (10:30 +0800)
Change-Id: Ifd7813126ffea3623a161c5b3295808e5fa283a4
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/lcm/nf/views/instantiate_vnf_view.py

index 80529b2..23a979a 100644 (file)
@@ -24,6 +24,7 @@ from lcm.nf.serializers.instantiate_vnf_request import InstantiateVnfRequestSeri
 from lcm.nf.serializers.job_identifier import JobIdentifierSerializer\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 .common import view_safe_call_with_log\r
@@ -50,6 +51,8 @@ class InstantiateVnfView(APIView):
         vnf_insts = NfInstModel.objects.filter(nfinstid=instanceid)\r
         if not vnf_insts.exists():\r
             raise NFLCMExceptionNotFound("VNF instanceid(%s) does not exist." % instanceid)\r
+        if vnf_insts[0].status == 'INSTANTIATED':\r
+            raise NFLCMExceptionConflict('VNF(%s) is already INSTANTIATED.' % instanceid)\r
 \r
         job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid)\r
         JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")\r