summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryunlong ying <ying.yunlong@zte.com.cn>2019-04-08 01:38:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-08 01:38:31 +0000
commit55ecb6040972af207bed99ad55bfb0ee29e601ae (patch)
treeeded9508b0ebcb3affd9f8dcee00ca665beb2c64
parent8f09fb9cf1574253117957bf3f780ce21bf17a67 (diff)
parent7afd4fcbd4395801a210fb1323131904eece1d14 (diff)
Merge "Add vnf exist check for inst vnf"
-rw-r--r--lcm/lcm/nf/views/instantiate_vnf_view.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lcm/lcm/nf/views/instantiate_vnf_view.py b/lcm/lcm/nf/views/instantiate_vnf_view.py
index b285cc8c..80529b2d 100644
--- a/lcm/lcm/nf/views/instantiate_vnf_view.py
+++ b/lcm/lcm/nf/views/instantiate_vnf_view.py
@@ -23,7 +23,9 @@ from rest_framework.views import APIView
from lcm.nf.serializers.instantiate_vnf_request import InstantiateVnfRequestSerializer
from lcm.nf.serializers.job_identifier import JobIdentifierSerializer
from lcm.pub.exceptions import NFLCMException
+from lcm.pub.exceptions import NFLCMExceptionNotFound
from lcm.pub.utils.jobutil import JobUtil
+from lcm.pub.database.models import NfInstModel
from .common import view_safe_call_with_log
logger = logging.getLogger(__name__)
@@ -45,6 +47,10 @@ class InstantiateVnfView(APIView):
if not instantiate_vnf_request_serializer.is_valid():
raise NFLCMException(instantiate_vnf_request_serializer.errors)
+ vnf_insts = NfInstModel.objects.filter(nfinstid=instanceid)
+ if not vnf_insts.exists():
+ raise NFLCMExceptionNotFound("VNF instanceid(%s) does not exist." % instanceid)
+
job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid)
JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")
InstantiateVnf(instantiate_vnf_request_serializer.data, instanceid, job_id).start()