diff options
author | 2019-04-11 10:30:49 +0800 | |
---|---|---|
committer | 2019-04-11 10:30:49 +0800 | |
commit | b10195f3df9535641c6a142dfededf770b201ad0 (patch) | |
tree | ecc5d0f0235367f4e8026af9617257b1da674ac9 | |
parent | 89fd50ca268ed9b9ed9904ad578c1416bb81f90d (diff) |
Add precheck to inst vnf
Change-Id: Ifd7813126ffea3623a161c5b3295808e5fa283a4
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/views/instantiate_vnf_view.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lcm/lcm/nf/views/instantiate_vnf_view.py b/lcm/lcm/nf/views/instantiate_vnf_view.py index 80529b2d..23a979ae 100644 --- a/lcm/lcm/nf/views/instantiate_vnf_view.py +++ b/lcm/lcm/nf/views/instantiate_vnf_view.py @@ -24,6 +24,7 @@ from lcm.nf.serializers.instantiate_vnf_request import InstantiateVnfRequestSeri from lcm.nf.serializers.job_identifier import JobIdentifierSerializer
from lcm.pub.exceptions import NFLCMException
from lcm.pub.exceptions import NFLCMExceptionNotFound
+from lcm.pub.exceptions import NFLCMExceptionConflict
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.database.models import NfInstModel
from .common import view_safe_call_with_log
@@ -50,6 +51,8 @@ class InstantiateVnfView(APIView): vnf_insts = NfInstModel.objects.filter(nfinstid=instanceid)
if not vnf_insts.exists():
raise NFLCMExceptionNotFound("VNF instanceid(%s) does not exist." % instanceid)
+ if vnf_insts[0].status == 'INSTANTIATED':
+ raise NFLCMExceptionConflict('VNF(%s) is already INSTANTIATED.' % instanceid)
job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid)
JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")
|