summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbiancunkang <bian.cunkang@zte.com.cn>2018-08-11 14:49:06 +0800
committerbiancunkang <bian.cunkang@zte.com.cn>2018-08-11 14:49:06 +0800
commit906066a651385fac2eb5d57c93ef428cfef1f01e (patch)
tree9fa854e22b0521a4af088e433996469584ba32cc
parent148f5bd1f58b2b2f65d4e5783189b965b43925a2 (diff)
Change in terminate
Handle the exception in terminate_vnf_view.py Change-Id: Ia3ecc5f886fda9075d02f2cf46a7bc6bc2d769f7 Issue-ID: VFC-1015 Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
-rw-r--r--lcm/lcm/nf/biz/terminate_vnf.py12
-rw-r--r--lcm/lcm/nf/views/terminate_vnf_view.py12
2 files changed, 9 insertions, 15 deletions
diff --git a/lcm/lcm/nf/biz/terminate_vnf.py b/lcm/lcm/nf/biz/terminate_vnf.py
index 5d51512f..e23d5ef7 100644
--- a/lcm/lcm/nf/biz/terminate_vnf.py
+++ b/lcm/lcm/nf/biz/terminate_vnf.py
@@ -14,7 +14,6 @@
import json
import logging
-import traceback
from threading import Thread
from lcm.nf.const import VNF_STATUS, RESOURCE_MAP
@@ -41,7 +40,6 @@ class TerminateVnf(Thread):
self.inst_resource = {'volumn': [], 'network': [], 'subnet': [], 'port': [], 'flavor': [], 'vm': []}
def run(self):
- try:
if self.term_pre():
self.grant_resource()
self.query_inst_resource()
@@ -49,11 +47,6 @@ class TerminateVnf(Thread):
self.delete_resource()
self.lcm_notify()
JobUtil.add_job_status(self.job_id, 100, "Terminate Vnf success.")
- except NFLCMException as e:
- self.vnf_term_failed_handle(e.message)
- except Exception as e:
- logger.error(e.message)
- self.vnf_term_failed_handle(traceback.format_exc())
def term_pre(self):
vnf_insts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
@@ -201,8 +194,3 @@ class TerminateVnf(Thread):
logger.info('Send notify request to nfvo')
resp = notify_lcm_to_nfvo(json.dumps(self.notify_data))
logger.info('Lcm notify end, response: %s' % resp)
-
- def vnf_term_failed_handle(self, error_msg):
- logger.error('VNF termination failed, detail message: %s' % error_msg)
- NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time())
- JobUtil.add_job_status(self.job_id, 255, error_msg)
diff --git a/lcm/lcm/nf/views/terminate_vnf_view.py b/lcm/lcm/nf/views/terminate_vnf_view.py
index c1903b76..261c55e1 100644
--- a/lcm/lcm/nf/views/terminate_vnf_view.py
+++ b/lcm/lcm/nf/views/terminate_vnf_view.py
@@ -25,7 +25,8 @@ from lcm.nf.serializers.terminate_vnf_req import TerminateVnfRequestSerializer
from lcm.nf.serializers.job_identifier import JobIdentifierSerializer
from lcm.pub.exceptions import NFLCMException
from lcm.pub.utils.jobutil import JobUtil
-
+from lcm.pub.utils.timeutil import now_time
+from lcm.pub.database.models import NfInstModel
logger = logging.getLogger(__name__)
@@ -55,9 +56,14 @@ class TerminateVnfView(APIView):
return Response(data=terminate_vnf_response_serializer.data, status=status.HTTP_202_ACCEPTED)
except NFLCMException as e:
- logger.error(e.message)
+ self.vnf_term_failed_handle(e.message)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except Exception as e:
logger.error(e.message)
- logger.error(traceback.format_exc())
+ self.vnf_term_failed_handle(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+ def vnf_term_failed_handle(self, error_msg):
+ logger.error('VNF termination failed, detail message: %s' % error_msg)
+ NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time())
+ JobUtil.add_job_status(self.job_id, 255, error_msg)