diff options
-rw-r--r-- | lcm/ns/biz/ns_terminate.py | 10 | ||||
-rw-r--r-- | lcm/pub/msapi/nslcm.py | 5 |
2 files changed, 11 insertions, 4 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/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 |