summaryrefslogtreecommitdiffstats
path: root/gvnfmadapter
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-11-13 18:24:43 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-11-13 18:24:43 +0800
commite206e7d40c77a65edf6fdc631a3f353269f8e0ed (patch)
tree99601f176db222e4db727e2d80b18dbfe9587c5f /gvnfmadapter
parent2d398c5745587104a290a1437fbdf19f4cb348cd (diff)
Fix vnf term logic
Change-Id: I6e90db39ad27d4b250a476157f981b46ad8297a3 Issue-ID: VFC-1163 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'gvnfmadapter')
-rw-r--r--gvnfmadapter/driver/interfaces/tests.py3
-rw-r--r--gvnfmadapter/driver/interfaces/views.py23
2 files changed, 11 insertions, 15 deletions
diff --git a/gvnfmadapter/driver/interfaces/tests.py b/gvnfmadapter/driver/interfaces/tests.py
index c4e1791..61c8941 100644
--- a/gvnfmadapter/driver/interfaces/tests.py
+++ b/gvnfmadapter/driver/interfaces/tests.py
@@ -121,8 +121,7 @@ class InterfacesTest(TestCase):
r3 = [0, json.JSONEncoder().encode(None), "200"]
mock_call_req.side_effect = [r1, r2, r1, job_ret, r1, r3]
response = self.client.post("/api/gvnfmdriver/v1/ztevnfmid/vnfs/2/terminate")
- self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)
- self.assertEqual(None, response.data)
+ self.assertEqual(status.HTTP_201_CREATED, response.status_code)
@mock.patch.object(restcall, 'call_req')
def test_query_vnf(self, mock_call_req):
diff --git a/gvnfmadapter/driver/interfaces/views.py b/gvnfmadapter/driver/interfaces/views.py
index 7cbbfb8..b5dee0e 100644
--- a/gvnfmadapter/driver/interfaces/views.py
+++ b/gvnfmadapter/driver/interfaces/views.py
@@ -109,7 +109,6 @@ class VnfTermInfo(APIView):
)
def post(self, request, vnfmtype, vnfmid, vnfInstanceId):
logger.debug("terminate_vnf--post::> %s" % request.data)
- logger.debug("Terminate vnf begin!")
vnfm_id = vnfmid
try:
term_type = ignorcase_get(request.data, "terminationType")
@@ -126,20 +125,18 @@ class VnfTermInfo(APIView):
logger.debug("terminate_vnf: response data=[%s]", resp)
jobId = ignorcase_get(resp, "jobId")
- gracefulTerminationTimeout = ignorcase_get(request.data, "gracefulTerminationTimeout")
- logger.debug("wait4job: vnfm_id=[%s],jobId=[%s],gracefulTerminationTimeout=[%s]",
- vnfm_id, jobId, gracefulTerminationTimeout)
- resp = wait4job(vnfm_id, jobId, gracefulTerminationTimeout)
+ logger.debug("wait4job: vnfm_id=[%s],jobId=[%s]", vnfm_id, jobId)
+ resp = wait4job(vnfm_id, jobId)
logger.debug("[wait4job] response=[%s]", resp)
- logger.debug("Delete vnf start!")
- logger.debug("do_deletevnf: vnfm_id=[%s],vnfInstanceId=[%s],request data=[%s]",
- vnfm_id, vnfInstanceId, request.data)
- resp = do_deletevnf(vnfm_id, vnfInstanceId, request.data)
+ resp = do_deletevnf(vnfm_id, vnfInstanceId)
logger.debug("do_deletevnf: response data=[%s]", resp)
- logger.debug("Delete vnf end!")
- return Response(data=resp, status=status.HTTP_204_NO_CONTENT)
+ resp_data = {
+ "vnfInstanceId": vnfInstanceId,
+ "jobId": jobId
+ }
+ return Response(data=resp_data, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e:
logger.error('Terminate vnf failed, detail message: %s' % e.message)
return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -606,8 +603,8 @@ def do_terminatevnf(vnfm_id, vnfInstanceId, data):
return json.JSONDecoder().decode(ret[1])
-def do_deletevnf(vnfm_id, vnfInstanceId, data):
- logger.debug("[%s] request.data=%s", fun_name(), data)
+def do_deletevnf(vnfm_id, vnfInstanceId):
+ logger.debug("[%s] vnfm_id=%s, vnfInstanceId=%s", fun_name(), vnfm_id, vnfInstanceId)
vnfm_info = get_vnfminfo_from_nslcm(vnfm_id)
logger.debug("[do_deletevnf] vnfm_info=[%s]", vnfm_info)
ret = call_vnfm("api/vnflcm/v1/vnf_instances/%s" % vnfInstanceId, "DELETE", vnfm_info)