From 5464ccb452d84a89ed70e056439c73cd7da0e31d Mon Sep 17 00:00:00 2001 From: hongyuzhao Date: Thu, 19 Dec 2019 15:16:02 +0800 Subject: Fix bug for deleting subscription in ns termination Change-Id: I47bb40a5275c36c189cf6f8bf57a1bf6ec1f84b5 Issue-ID: VFC-1594 Signed-off-by: hongyuzhao --- lcm/lcm/nf/biz/create_subscription.py | 17 +++++++++-------- lcm/lcm/nf/biz/terminate_vnf.py | 4 ++-- lcm/lcm/pub/utils/notificationsutil.py | 3 ++- lcm/tox.ini | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lcm/lcm/nf/biz/create_subscription.py b/lcm/lcm/nf/biz/create_subscription.py index 2b1f6064..5f981d0a 100644 --- a/lcm/lcm/nf/biz/create_subscription.py +++ b/lcm/lcm/nf/biz/create_subscription.py @@ -53,14 +53,15 @@ class CreateSubscription: def check_callbackuri_connection(self): logger.debug("SubscribeNotification-post::> Sending GET request " "to %s" % self.callback_uri) - try: - response = requests.get(self.callback_uri, timeout=2) - if response.status_code != status.HTTP_204_NO_CONTENT: - raise NFLCMException("callbackUri %s returns %s status " - "code." % (self.callback_uri, response.status_code)) - except Exception: - raise NFLCMException("callbackUri %s didn't return 204 status" - "code." % self.callback_uri) + retry_count = 3 + while retry_count > 0: + response = requests.get(self.callback_uri, timeout=10) + if response.status_code == status.HTTP_204_NO_CONTENT: + return + logger.debug("callbackUri %s returns %s status code." % (self.callback_uri, response.status_code)) + retry_count = - 1 + + raise NFLCMException("callbackUri %s didn't return 204 status." % self.callback_uri) def do_biz(self): self.subscription_id = str(uuid.uuid4()) diff --git a/lcm/lcm/nf/biz/terminate_vnf.py b/lcm/lcm/nf/biz/terminate_vnf.py index 2b04dc96..e18fad90 100644 --- a/lcm/lcm/nf/biz/terminate_vnf.py +++ b/lcm/lcm/nf/biz/terminate_vnf.py @@ -66,8 +66,8 @@ class TerminateVnf(Thread): self.lcm_op_occ = VnfLcmOpOcc( vnf_inst_id=nf_inst_id, lcm_op_id=job_id, - operation=OPERATION_TYPE.SCALE, - task=OPERATION_TASK.SCALE + operation=OPERATION_TYPE.TERMINATE, + task=OPERATION_TASK.TERMINATE ) def run(self): diff --git a/lcm/lcm/pub/utils/notificationsutil.py b/lcm/lcm/pub/utils/notificationsutil.py index fd4efa36..b57b470c 100644 --- a/lcm/lcm/pub/utils/notificationsutil.py +++ b/lcm/lcm/pub/utils/notificationsutil.py @@ -52,7 +52,8 @@ class NotificationsUtil(object): logger.info("Send Notifications to the callbackUri") filters = { "operationState": "operation_states", - "operation": "operation_types" + "operation": "operation_types", + "vnfInstanceId": "vnf_instance_filter" } subscriptions_filter = {v + "__contains": notification[k] for k, v in list(filters.items())} diff --git a/lcm/tox.ini b/lcm/tox.ini index 54f7ae87..6f61451f 100644 --- a/lcm/tox.ini +++ b/lcm/tox.ini @@ -23,5 +23,5 @@ commands = {[testenv]commands} [testenv:cov] -deps = coverage +deps = coverage==4.2 commands = coverage xml --omit="*test*,*__init__.py,*site-packages*" -- cgit 1.2.3-korg