summaryrefslogtreecommitdiffstats
path: root/gvnfmadapter
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2019-05-30 20:14:11 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2019-05-30 20:26:10 +0800
commit18f7f2fe4cbe096c9a692605956be8a10e61bf28 (patch)
treed9d2d6694531b8cc7dbec984060afe7133ab3616 /gvnfmadapter
parentc76a1afcfe44eff17e0935189b6a4f767771e138 (diff)
fix NS termination error
fix NS termination error in GVNFM adaptor Change-Id: Idf6bcbb616ce2d8be9683faef6bf4896cd7c445e Issue-ID: VFC-1409 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
Diffstat (limited to 'gvnfmadapter')
-rw-r--r--gvnfmadapter/driver/interfaces/views.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/gvnfmadapter/driver/interfaces/views.py b/gvnfmadapter/driver/interfaces/views.py
index 19cbc66..fa8a651 100644
--- a/gvnfmadapter/driver/interfaces/views.py
+++ b/gvnfmadapter/driver/interfaces/views.py
@@ -112,30 +112,35 @@ class VnfTermInfo(APIView):
logger.debug("terminate_vnf--post::> %s" % request.data)
vnfm_id = vnfmid
try:
- term_type = ignorcase_get(request.data, "terminationType")
- input_data = {
- "terminationType": term_type.upper() if term_type else "FORCEFUL"
- }
- term_timeout = ignorcase_get(request.data, "gracefulTerminationTimeout")
- if term_timeout:
- input_data["gracefulTerminationTimeout"] = int(term_timeout)
-
- logger.debug("do_terminatevnf: vnfm_id=[%s],vnfInstanceId=[%s],input_data=[%s]",
- vnfm_id, vnfInstanceId, input_data)
- resp = do_terminatevnf(vnfm_id, vnfInstanceId, input_data)
- logger.debug("terminate_vnf: response data=[%s]", resp)
+ vnf_info = do_queryvnf(request, vnfm_id, vnfInstanceId)
+ logger.debug("VNF instance info: %s" % vnf_info)
+ except GvnfmDriverException as e:
+ logger.debug('VNF already does not exist, detail message: %s' % e.message)
+ return Response(data={"vnfInstanceId": vnfInstanceId}, status=status.HTTP_201_CREATED)
- jobId = ignorcase_get(resp, "jobId")
- logger.debug("wait4job: vnfm_id=[%s],jobId=[%s]", vnfm_id, jobId)
- resp = wait4job(vnfm_id, jobId)
- logger.debug("[wait4job] response=[%s]", resp)
+ try:
+ if vnf_info.get("instantiationState", "") == "INSTANTIATED":
+ term_type = ignorcase_get(request.data, "terminationType")
+ input_data = {
+ "terminationType": term_type.upper() if term_type else "FORCEFUL"
+ }
+ term_timeout = ignorcase_get(request.data, "gracefulTerminationTimeout")
+ if term_timeout:
+ input_data["gracefulTerminationTimeout"] = int(term_timeout)
+
+ logger.debug("do_terminatevnf: vnfm_id=[%s],vnfInstanceId=[%s],input_data=[%s]",
+ vnfm_id, vnfInstanceId, input_data)
+ resp = do_terminatevnf(vnfm_id, vnfInstanceId, input_data)
+ logger.debug("terminate_vnf: response data=[%s]", resp)
+ jobId = ignorcase_get(resp, "jobId")
+ logger.debug("wait4job: vnfm_id=[%s],jobId=[%s]", vnfm_id, jobId)
+ resp = wait4job(vnfm_id, jobId)
+ logger.debug("[wait4job] response=[%s]", resp)
resp = do_deletevnf(vnfm_id, vnfInstanceId)
logger.debug("do_deletevnf: response data=[%s]", resp)
-
resp_data = {
- "vnfInstanceId": vnfInstanceId,
- "jobId": jobId
+ "vnfInstanceId": vnfInstanceId
}
return Response(data=resp_data, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e: