From d5f2d43c566ac4f14c173a5417ab3bec20af452b Mon Sep 17 00:00:00 2001 From: fujinhua Date: Wed, 20 Mar 2019 17:04:23 +0800 Subject: Update api adaptor for terminate vnf Change-Id: I75704c9c1fea9666ce4aef0970484525214c6157 Issue-ID: VFC-1307 Signed-off-by: fujinhua --- zte/vmanager/driver/interfaces/tests.py | 2 +- zte/vmanager/driver/interfaces/views.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py index c0c062c8..5e975f04 100644 --- a/zte/vmanager/driver/interfaces/tests.py +++ b/zte/vmanager/driver/interfaces/tests.py @@ -181,7 +181,7 @@ class InterfacesTest(TestCase): "gracefulTerminationTimeout": 120 } response = self.client.post( - "/api/ztevnfmdriver/v1/ztevnfmid/vnfs/vbras_innstance_id/terminate", data=req_data) + "/api/ztevnfmdriver/v1/ztevnfmid/vnfs/1/terminate", data=req_data) self.assertEqual(status.HTTP_200_OK, response.status_code) expect_resp_data = {"jobId": "1", "vnfInstanceId": "1"} diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index 11dd6a09..fd99a92d 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -193,6 +193,7 @@ class TerminateVnf(APIView): def post(self, request, vnfmid, vnfInstanceId): try: logger.debug("[%s] request.data=%s", fun_name(), request.data) + logger.debug("vnfmid=%s, vnfInstanceId=%s", vnfmid, vnfInstanceId) terminate_vnf_request_serializer = TerminateVnfRequestSerializer(data=request.data) if not terminate_vnf_request_serializer.is_valid(): raise Exception(terminate_vnf_request_serializer.errors) @@ -208,15 +209,15 @@ class TerminateVnf(APIView): user=ignorcase_get(vnfm_info, "userName"), passwd=ignorcase_get(vnfm_info, "password"), auth_type=restcall.rest_no_auth, - resource="v1/vnfs/%s" % vnfInstanceId, + resource="v1/vnfs/%s?NFVOID=1&VNFMID=%s" % (vnfInstanceId, vnfmid), method='delete', - content=json.JSONEncoder().encode(terminate_vnf_request_serializer.data)) + content='{}') if ret[0] != 0: raise Exception(ret[1]) resp = json.JSONDecoder().decode(ret[1]) resp_data = { - "vnfInstanceId": ignorcase_get(resp, "VNFInstanceID"), + "vnfInstanceId": vnfInstanceId, "jobId": ignorcase_get(resp, "JobId") } logger.debug("[%s]resp_data=%s", fun_name(), resp_data) -- cgit 1.2.3-korg