diff options
-rw-r--r-- | lcm/lcm/nf/views/instantiate_vnf_view.py | 6 |
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()
|