diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-30 17:28:19 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2018-08-30 17:28:19 +0800 |
commit | 6c67c86e11abaed2f34b2d7380bbb23e2ad8015e (patch) | |
tree | 4c4aa9db9b95839ee8b17e5ab0a27533aeebce4c | |
parent | b2021dd388849a35517f1ea94e1e52376e20afc4 (diff) |
Fix csit job error for vfc-nfvo-lcm
Change-Id: I1d427a4ef20228a371da3adab54ca2f61d8754a7
Issue-ID: INT-640
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/ns_vnfs/tests/tests.py | 4 | ||||
-rw-r--r-- | lcm/ns_vnfs/urls.py | 3 | ||||
-rw-r--r-- | lcm/ns_vnfs/views/views.py | 16 | ||||
-rw-r--r-- | lcm/pub/msapi/nslcm.py | 2 |
4 files changed, 14 insertions, 11 deletions
diff --git a/lcm/ns_vnfs/tests/tests.py b/lcm/ns_vnfs/tests/tests.py index 37add61b..b70d00e3 100644 --- a/lcm/ns_vnfs/tests/tests.py +++ b/lcm/ns_vnfs/tests/tests.py @@ -199,8 +199,8 @@ class TestTerminateVnfViews(TestCase): "terminationType": "forceful", "gracefulTerminationTimeout": "600"} - response = self.client.post("/api/nslcm/v1/ns/vnfs/%s" % self.nf_inst_id, data=req_data) - self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code) + response = self.client.post("/api/nslcm/v1/ns/terminatevnf/%s" % self.nf_inst_id, data=req_data) + self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code) @mock.patch.object(restcall, 'call_req') def test_terminate_vnf(self, mock_call_req): diff --git a/lcm/ns_vnfs/urls.py b/lcm/ns_vnfs/urls.py index dd555bf5..49a2229a 100644 --- a/lcm/ns_vnfs/urls.py +++ b/lcm/ns_vnfs/urls.py @@ -15,13 +15,14 @@ from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns from lcm.ns_vnfs.views.views import LcmNotify, NfScaleView, NfVerifyView -from lcm.ns_vnfs.views.views import NfView, NfDetailView, NfGrant, NfPlacement +from lcm.ns_vnfs.views.views import NfView, NfDetailView, NfGrant, NfPlacement, NfTerminate from lcm.ns_vnfs.views.views import NfVnfmInfoView, NfVimInfoView from lcm.ns_vnfs.views.grant_vnf_views import VnfGrantView, VnfNotifyView urlpatterns = [ url(r'^api/nslcm/v1/ns/vnfs$', NfView.as_view()), url(r'^api/nslcm/v1/ns/vnfs/(?P<vnfinstid>[0-9a-zA-Z_-]+)$', NfDetailView.as_view()), + url(r'^api/nslcm/v1/ns/terminatevnf/(?P<vnfinstid>[0-9a-zA-Z_-]+)$', NfTerminate.as_view()), url(r'^api/nslcm/v1/ns/grantvnf$', NfGrant.as_view()), url(r'^api/nslcm/v1/ns/placevnf$', NfPlacement.as_view()), url(r'^api/nslcm/v1/ns/(?P<vnfmid>[0-9a-zA-Z_-]+)/ns_vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', LcmNotify.as_view()), diff --git a/lcm/ns_vnfs/views/views.py b/lcm/ns_vnfs/views/views.py index 517238b3..e3a6bbf9 100644 --- a/lcm/ns_vnfs/views/views.py +++ b/lcm/ns_vnfs/views/views.py @@ -108,23 +108,25 @@ class NfDetailView(APIView): return Response(status=status.HTTP_200_OK, data=rsp) + +class NfTerminate(APIView): @swagger_auto_schema( request_body=TerminateVnfReqSerializer(), responses={ - status.HTTP_200_OK: TerminateVnfRespSerializer(), + status.HTTP_202_ACCEPTED: TerminateVnfRespSerializer(), status.HTTP_409_CONFLICT: "Inner error" } ) - def post(self, request_paras, vnfinstid): - logger.debug("VnfTerminateView--post::> %s, %s", vnfinstid, request_paras.data) + def post(self, request, vnfinstid): + logger.debug("NfTerminate--post::> %s, %s", vnfinstid, request.data) - req_serializer = TerminateVnfReqSerializer(data=request_paras.data) + req_serializer = TerminateVnfReqSerializer(data=request.data) if not req_serializer.is_valid(): logger.error(req_serializer.errors) vnf_inst_id = vnfinstid - terminationType = ignore_case_get(request_paras.data, 'terminationType') - gracefulTerminationTimeout = ignore_case_get(request_paras.data, 'gracefulTerminationTimeout') + terminationType = ignore_case_get(request.data, 'terminationType') + gracefulTerminationTimeout = ignore_case_get(request.data, 'gracefulTerminationTimeout') job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, vnf_inst_id) data = {'terminationType': terminationType, 'gracefulTerminationTimeout': gracefulTerminationTimeout} logger.debug("data=%s", data) @@ -139,7 +141,7 @@ class NfDetailView(APIView): if not resp_serializer.is_valid(): logger.error(resp_serializer.errors) - return Response(data=rsp, status=status.HTTP_201_CREATED) + return Response(data=rsp, status=status.HTTP_202_ACCEPTED) class NfGrant(APIView): diff --git a/lcm/pub/msapi/nslcm.py b/lcm/pub/msapi/nslcm.py index 44d8f843..921e03f7 100644 --- a/lcm/pub/msapi/nslcm.py +++ b/lcm/pub/msapi/nslcm.py @@ -30,7 +30,7 @@ def call_from_ns_cancel_resource(res_type, instid): else: # vnf method = "POST" - uri = '/api/nslcm/v1/ns/vnfs/%s' % instid + uri = '/api/nslcm/v1/ns/terminatevnf/%s' % instid req_param = {} ret = req_by_msb(uri, method, json.dumps(req_param)) logger.info("[NS terminate] call vnfm [%s] result:%s" % (res_type, ret)) |