diff options
-rw-r--r-- | lcm/ns/biz/ns_terminate.py | 10 | ||||
-rw-r--r-- | lcm/ns/views/term_ns_view.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/terminate_nfs.py | 5 | ||||
-rw-r--r-- | lcm/pub/msapi/nslcm.py | 5 | ||||
-rw-r--r-- | lcm/pub/msapi/resmgr.py | 2 | ||||
-rw-r--r-- | lcm/pub/utils/jobutil.py | 2 |
6 files changed, 20 insertions, 6 deletions
diff --git a/lcm/ns/biz/ns_terminate.py b/lcm/ns/biz/ns_terminate.py index 4dc8d841..95f5e6a1 100644 --- a/lcm/ns/biz/ns_terminate.py +++ b/lcm/ns/biz/ns_terminate.py @@ -124,11 +124,17 @@ class TerminateNsService(threading.Thread): JobUtil.add_job_status(self.job_id, cur_progress, job_msg) def delete_vnf(self, nf_instid): - ret = call_from_ns_cancel_resource('vnf', nf_instid) + term_param = { + "terminationType": self.terminate_type + } + if self.terminate_timeout: + term_param["gracefulTerminationTimeout"] = int(self.terminate_timeout) + ret = call_from_ns_cancel_resource('vnf', nf_instid, term_param) if ret[0] != 0: + logger.error("Terminate VNF(%s) failed: %s", nf_instid, ret[1]) return False job_info = json.JSONDecoder().decode(ret[1]) - vnf_job_id = ignore_case_get(job_info, "jobid") + vnf_job_id = ignore_case_get(job_info, "jobId") return self.wait_delete_vnf_job_finish(vnf_job_id) def wait_delete_vnf_job_finish(self, vnf_job_id): diff --git a/lcm/ns/views/term_ns_view.py b/lcm/ns/views/term_ns_view.py index a8c9a42d..aa9a8644 100644 --- a/lcm/ns/views/term_ns_view.py +++ b/lcm/ns/views/term_ns_view.py @@ -45,7 +45,7 @@ class TerminateNSView(APIView): termination_type = ignore_case_get(request.data, 'terminationType') graceful_termination_timeout = ignore_case_get(request.data, 'gracefulTerminationTimeout') - job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, ns_instance_id) + job_id = JobUtil.create_job("NS", JOB_TYPE.TERMINATE_NS, ns_instance_id) TerminateNsService(ns_instance_id, termination_type, graceful_termination_timeout, job_id).start() resp_serializer = NsOperateJobSerializer(data={'jobId': job_id}) diff --git a/lcm/ns_vnfs/biz/terminate_nfs.py b/lcm/ns_vnfs/biz/terminate_nfs.py index f921edd0..7cdea1c8 100644 --- a/lcm/ns_vnfs/biz/terminate_nfs.py +++ b/lcm/ns_vnfs/biz/terminate_nfs.py @@ -43,6 +43,11 @@ class TerminateVnfs(threading.Thread): self.vnfm_job_id = '' self.terminationType = data['terminationType'] self.gracefulTerminationTimeout = data['gracefulTerminationTimeout'] + if not self.gracefulTerminationTimeout: + self.gracefulTerminationTimeout = 120 + else: + self.gracefulTerminationTimeout = int(self.gracefulTerminationTimeout) + self.initdata() def run(self): diff --git a/lcm/pub/msapi/nslcm.py b/lcm/pub/msapi/nslcm.py index 4dd0d223..f46ebc4a 100644 --- a/lcm/pub/msapi/nslcm.py +++ b/lcm/pub/msapi/nslcm.py @@ -20,7 +20,7 @@ from lcm.pub.utils.restcall import req_by_msb logger = logging.getLogger(__name__) -def call_from_ns_cancel_resource(res_type, instid): +def call_from_ns_cancel_resource(res_type, instid, req_param=None): method = "DELETE" if res_type == 'vl': uri = '/api/nslcm/v1/ns/vls/%s' % instid @@ -32,7 +32,8 @@ def call_from_ns_cancel_resource(res_type, instid): # vnf method = "POST" uri = '/api/nslcm/v1/ns/terminatevnf/%s' % instid - req_param = {} + if not req_param: + req_param = {} ret = req_by_msb(uri, method, json.dumps(req_param)) logger.info("[NS terminate] call res_type [%s] result:%s" % (res_type, ret)) return ret diff --git a/lcm/pub/msapi/resmgr.py b/lcm/pub/msapi/resmgr.py index e6bc3bb3..db2c5e20 100644 --- a/lcm/pub/msapi/resmgr.py +++ b/lcm/pub/msapi/resmgr.py @@ -62,6 +62,8 @@ def grant_vnf(req_param): if isinstance(vim, list): vim = vim[0] vim_id = vim["vimId"] + if "vimId" in vim: + vim_id = vim["vimId"] grant_rsp = { "vim": { "vimId": vim_id, diff --git a/lcm/pub/utils/jobutil.py b/lcm/pub/utils/jobutil.py index 69fa2866..30c7b444 100644 --- a/lcm/pub/utils/jobutil.py +++ b/lcm/pub/utils/jobutil.py @@ -30,7 +30,7 @@ JOB_STATUS = enum(PROCESSING=0, FINISH=1) JOB_MODEL_STATUS = enum(STARTED='started', PROCESSING='processing', FINISHED='finished', ERROR='error', TIMEOUT='timeout') JOB_TYPE = enum(CREATE_VNF="create vnf", TERMINATE_VNF="terminate vnf", GRANT_VNF="grant vnf", MANUAL_SCALE_VNF="manual scale vnf", - HEAL_VNF="heal vnf") + HEAL_VNF="heal vnf", TERMINATE_NS="terminate ns") class JobUtil(object): |