import time
import traceback
import uuid
+from threading import Thread
from rest_framework import status
logger = logging.getLogger(__name__)
+class BuildInWorkflowThread(Thread):
+ def __init__(self, plan_input):
+ Thread.__init__(self)
+ self.plan_input = plan_input
+
+ def run(self):
+ build_in.run_ns_instantiate(self.plan_input)
+
+
class InstantNSService(object):
def __init__(self, ns_inst_id, plan_content):
self.ns_inst_id = ns_inst_id
plan_dict = json.JSONDecoder().decode(dst_plan)
for vnf in ignore_case_get(plan_dict, "vnfs"):
vnfd_id = vnf['properties']['id']
- # vnfd = NfPackageModel.objects.get(vnfdid=vnfd_id)
- # vnfpackage_info = query_vnfpackage_by_id(vnfd_id)
- # vnfd_model = json.JSONDecoder().decode(ignore_case_get(vnfpackage_info["packageInfo"], "vnfdModel"))
- # vnfm_type = vnfd_model["metadata"].get("vnfmType", "ztevmanagerdriver")
- vnfm_type = vnf['properties'].get("nf_type", "ztevmanagerdriver")
+ vnfm_type = vnf['properties'].get("nf_type", "undefined")
vimid = self.get_vnf_vim_id(vim_id, location_constraints, vnfd_id)
vnfm_info = select_vnfm(vnfm_type=vnfm_type, vim_id=vimid)
params_vnf.append({
def start_buildin_workflow(self, job_id, plan_input):
JobUtil.add_job_status(job_id, 10, 'NS inst(%s) buildin workflow started.' % self.ns_inst_id)
- build_in.run_ns_instantiate(plan_input)
+ BuildInWorkflowThread(plan_input).start()
return dict(data={'jobId': job_id}, status=status.HTTP_200_OK)
def get_vnf_vim_id(self, vim_id, location_constraints, vnfdid):