Fix bug for deleting subscription in ns termination 90/99790/3
authorhongyuzhao <zhao.hongyu@zte.com.cn>
Thu, 19 Dec 2019 07:16:02 +0000 (15:16 +0800)
committerhongyuzhao <zhao.hongyu@zte.com.cn>
Sat, 4 Jan 2020 03:31:14 +0000 (11:31 +0800)
Change-Id: I47bb40a5275c36c189cf6f8bf57a1bf6ec1f84b5
Issue-ID: VFC-1594
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
lcm/lcm/nf/biz/create_subscription.py
lcm/lcm/nf/biz/terminate_vnf.py
lcm/lcm/pub/utils/notificationsutil.py
lcm/tox.ini

index 2b1f606..5f981d0 100644 (file)
@@ -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())
index 2b04dc9..e18fad9 100644 (file)
@@ -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):
index fd4efa3..b57b470 100644 (file)
@@ -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())}
 
index 54f7ae8..6f61451 100644 (file)
@@ -23,5 +23,5 @@ commands =
   {[testenv]commands}
 
 [testenv:cov]
-deps = coverage
+deps = coverage==4.2
 commands = coverage xml --omit="*test*,*__init__.py,*site-packages*"