summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-08 09:16:15 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-08 09:17:03 +0800
commit7afd4fcbd4395801a210fb1323131904eece1d14 (patch)
tree54e64b43bce00c800559bd0ba69fce90d5630617
parent8209c63d711ff4d3c705ec563d526d6444025897 (diff)
Add vnf exist check for inst vnf
Change-Id: I3872c4a88e368ce3253375a4bb0b143b56d1e422 Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-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()