From 7afd4fcbd4395801a210fb1323131904eece1d14 Mon Sep 17 00:00:00 2001 From: fujinhua Date: Mon, 8 Apr 2019 09:16:15 +0800 Subject: Add vnf exist check for inst vnf Change-Id: I3872c4a88e368ce3253375a4bb0b143b56d1e422 Issue-ID: VFC-1306 Signed-off-by: fujinhua --- lcm/lcm/nf/views/instantiate_vnf_view.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lcm') 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() -- cgit 1.2.3-korg