diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-11-13 11:50:38 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-11-13 11:50:38 +0800 |
commit | 68aff71e67be9946a4babffdedb4c8bb6726e5a3 (patch) | |
tree | 64d4cd56d41f8e25fe631b0928167558bf190d22 | |
parent | da0475d37a7fc6310b3a5f0ac407be408bb06caf (diff) |
Fix ns term logic
Change-Id: Ie814becd8f365d5e1eeb39dd09719f3c09468cda
Issue-ID: VFC-1163
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-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 5b93f58d..18d9925b 100644 --- a/lcm/ns/biz/ns_terminate.py +++ b/lcm/ns/biz/ns_terminate.py @@ -122,11 +122,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 921e03f7..1ea9f11a 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 @@ -31,7 +31,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 vnfm [%s] result:%s" % (res_type, ret)) return ret |