Fix bug for delete subscription in ns termination 89/99789/5
authorhongyuzhao <zhao.hongyu@zte.com.cn>
Thu, 19 Dec 2019 07:00:04 +0000 (15:00 +0800)
committerhongyuzhao <zhao.hongyu@zte.com.cn>
Sat, 4 Jan 2020 03:34:38 +0000 (11:34 +0800)
Change-Id: I4a0b90c6947a99a120fa6aa3a28482cf4fc981e2
Issue-ID: VFC-1594
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
lcm/ns/views/deprecated/term_ns_view.py
lcm/ns_vnfs/biz/subscribe.py
lcm/ns_vnfs/biz/terminate_nfs.py
tox.ini

index 6d37f30..0e3a485 100644 (file)
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import logging
+import time
 
 from drf_yasg.utils import swagger_auto_schema
 from rest_framework import status
@@ -47,6 +48,7 @@ class NSTerminateView(APIView):
             raise BadRequestException(req_serializer.errors)
 
         job_id = JobUtil.create_job(JOB_TYPE.NS, JOB_ACTION.TERMINATE, ns_instance_id)
+        time.sleep(2)
         TerminateNsService(ns_instance_id, job_id, request.data).start()
 
         resp_serializer = _NsOperateJobSerializer(data={'jobId': job_id})
index 2de67ca..40f4059 100644 (file)
@@ -19,7 +19,6 @@ from lcm.pub.database.models import SubscriptionModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.extsys import get_vnfm_by_id
 from lcm.pub.utils.restcall import req_by_msb
-from lcm.pub.utils.values import ignore_case_get
 from lcm.pub.config import config as pub_config
 
 logger = logging.getLogger(__name__)
@@ -130,7 +129,7 @@ class SubscriptionDeletion(object):
 
     def send_subscription_deletion_request(self):
         if self.subscription:
-            self.subscription_id = ignore_case_get(self.subscription.__dict__, 'id')
+            self.subscription_id = self.subscription.subscription_id
             ret = req_by_msb('api/gvnfmdriver/v1/%s/subscriptions/%s' % (self.vnfm_id, self.subscription_id), 'DELETE')
             if ret[0] != 0:
                 logger.error('Status code is %s, detail is %s.', ret[2], ret[1])
index 1dec71d..0205535 100644 (file)
@@ -140,7 +140,7 @@ class TerminateVnfs(threading.Thread):
 
     def delete_subscription(self):
         try:
-            SubscriptionDeletion(self.vnfm_inst_id, self.vnf_inst_id).do_biz()
+            SubscriptionDeletion(self.vnfm_inst_id, self.vnf_uuid).do_biz()
         except Exception as e:
             logger.error("delete_subscription failed: %s", e.args[0])
 
diff --git a/tox.ini b/tox.ini
index cd62443..fb27ec5 100644 (file)
--- a/tox.ini
+++ b/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*"