diff options
author | hongyuzhao <zhao.hongyu@zte.com.cn> | 2019-07-22 10:55:20 +0800 |
---|---|---|
committer | hongyuzhao <zhao.hongyu@zte.com.cn> | 2019-07-22 14:14:20 +0800 |
commit | 75b97da489fb4d0996a6dfd78a36dc87736655de (patch) | |
tree | 2e3c89ee05ffc3b361cb12b12b9fe8312cd0b341 | |
parent | 672d3f46cee0772896ec06333bb620b7ac53a056 (diff) |
resolve python2->python3 issues
Change-Id: I9ae27189a7e796eb4bda00ee3b5bbcf91d0aeec1
Issue-ID: VFC-1429
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
-rw-r--r-- | lcm/jobs/views.py | 6 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/create_ns_view.py | 20 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/get_del_ns_view.py | 2 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/heal_ns_view.py | 4 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/scale_ns_views.py | 2 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/term_ns_view.py | 4 | ||||
-rw-r--r-- | lcm/ns/views/deprecated/update_ns_view.py | 4 | ||||
-rw-r--r-- | lcm/ns/views/sol/lcm_op_occs_view.py | 6 | ||||
-rw-r--r-- | lcm/ns/views/sol/ns_instances_views.py | 6 | ||||
-rw-r--r-- | lcm/ns/views/sol/subscriptions_view.py | 4 | ||||
-rw-r--r-- | lcm/ns_pnfs/views/pnf_view.py | 3 | ||||
-rw-r--r-- | lcm/ns_sfcs/views/detail_views.py | 2 | ||||
-rw-r--r-- | lcm/ns_vls/views/views.py | 10 | ||||
-rw-r--r-- | lcm/ns_vnfs/urls.py | 4 | ||||
-rw-r--r-- | lcm/ns_vnfs/views/vnf_views.py | 2 | ||||
-rw-r--r-- | lcm/samples/views.py | 5 |
16 files changed, 43 insertions, 41 deletions
diff --git a/lcm/jobs/views.py b/lcm/jobs/views.py index 71306c11..e2c1e9b8 100644 --- a/lcm/jobs/views.py +++ b/lcm/jobs/views.py @@ -60,8 +60,8 @@ class JobView(APIView): resp_serializer = JobQueryRespSerializer(data=ret) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - logger.debug("Leave JobView::get, response=%s", resp_serializer.data) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + logger.debug("Leave JobView::get, response=%s", ret) + return Response(data=ret, status=status.HTTP_200_OK) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) @@ -94,7 +94,7 @@ class JobView(APIView): JobUtil.add_job_status(job_id, job_up_req.progress, desc, error_code=err_code) job_update_resp = JobUpdResp('ok') resp_serializer = JobUpdRespSerializer(job_update_resp) - logger.debug("Leave JobView::post, response=%s", resp_serializer.data) + logger.debug("Leave JobView::post, response=%s", job_update_resp) return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED) except BadRequestException as e: job_update_resp = JobUpdResp('error', e.args[0]) diff --git a/lcm/ns/views/deprecated/create_ns_view.py b/lcm/ns/views/deprecated/create_ns_view.py index 428b5eca..8042515d 100644 --- a/lcm/ns/views/deprecated/create_ns_view.py +++ b/lcm/ns/views/deprecated/create_ns_view.py @@ -47,7 +47,7 @@ class CreateNSView(APIView): resp_serializer = _QueryNsRespSerializer(data=ret, many=True) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + return Response(data=ret, status=status.HTTP_200_OK) @swagger_auto_schema( request_body=_CreateNsReqSerializer(), @@ -81,14 +81,14 @@ class CreateNSView(APIView): ).do_biz() logger.debug("CreateNSView::post::ret={'nsInstanceId':%s}", ns_inst_id) - resp_serializer = _CreateNsRespSerializer( - data={'nsInstanceId': ns_inst_id, - 'nsInstanceName': 'nsInstanceName', - 'nsInstanceDescription': 'nsInstanceDescription', - 'nsdId': 123, - 'nsdInfoId': 456, - 'nsState': 'NOT_INSTANTIATED', - '_links': {'self': {'href': 'href'}}}) + ret = {'nsInstanceId': ns_inst_id, + 'nsInstanceName': 'nsInstanceName', + 'nsInstanceDescription': 'nsInstanceDescription', + 'nsdId': 123, + 'nsdInfoId': 456, + 'nsState': 'NOT_INSTANTIATED', + '_links': {'self': {'href': 'href'}}} + resp_serializer = _CreateNsRespSerializer(data=ret) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_201_CREATED) + return Response(data=ret, status=status.HTTP_201_CREATED) diff --git a/lcm/ns/views/deprecated/get_del_ns_view.py b/lcm/ns/views/deprecated/get_del_ns_view.py index db5a4466..89e780a9 100644 --- a/lcm/ns/views/deprecated/get_del_ns_view.py +++ b/lcm/ns/views/deprecated/get_del_ns_view.py @@ -47,7 +47,7 @@ class NSDetailView(APIView): resp_serializer = _QueryNsRespSerializer(data=ret[0]) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + return Response(data=ret[0], status=status.HTTP_200_OK) @swagger_auto_schema( request_body=None, diff --git a/lcm/ns/views/deprecated/heal_ns_view.py b/lcm/ns/views/deprecated/heal_ns_view.py index 473fea73..7dc5b509 100644 --- a/lcm/ns/views/deprecated/heal_ns_view.py +++ b/lcm/ns/views/deprecated/heal_ns_view.py @@ -52,5 +52,5 @@ class NSHealView(APIView): if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - logger.debug("Leave HealNSView::post ret=%s", resp_serializer.data) - return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED) + logger.debug("Leave HealNSView::post ret=%s", {'jobId': job_id}) + return Response(data={'jobId': job_id}, status=status.HTTP_202_ACCEPTED) diff --git a/lcm/ns/views/deprecated/scale_ns_views.py b/lcm/ns/views/deprecated/scale_ns_views.py index cef1e531..b60982c7 100644 --- a/lcm/ns/views/deprecated/scale_ns_views.py +++ b/lcm/ns/views/deprecated/scale_ns_views.py @@ -63,4 +63,4 @@ class NSManualScaleView(APIView): if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED) + return Response(data={'jobId': job_id}, status=status.HTTP_202_ACCEPTED) diff --git a/lcm/ns/views/deprecated/term_ns_view.py b/lcm/ns/views/deprecated/term_ns_view.py index dd6e98a3..6d37f30d 100644 --- a/lcm/ns/views/deprecated/term_ns_view.py +++ b/lcm/ns/views/deprecated/term_ns_view.py @@ -53,5 +53,5 @@ class NSTerminateView(APIView): if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - logger.debug("Leave TerminateNSView::post ret=%s", resp_serializer.data) - return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED) + logger.debug("Leave TerminateNSView::post ret=%s", {'jobId': job_id}) + return Response(data={'jobId': job_id}, status=status.HTTP_202_ACCEPTED) diff --git a/lcm/ns/views/deprecated/update_ns_view.py b/lcm/ns/views/deprecated/update_ns_view.py index 706f4991..cd423f87 100644 --- a/lcm/ns/views/deprecated/update_ns_view.py +++ b/lcm/ns/views/deprecated/update_ns_view.py @@ -54,5 +54,5 @@ class NSUpdateView(APIView): if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - logger.debug("Leave UpdateNSView::post ret=%s", resp_serializer.data) - return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED) + logger.debug("Leave UpdateNSView::post ret=%s", {'jobId': job_id}) + return Response(data={'jobId': job_id}, status=status.HTTP_202_ACCEPTED) diff --git a/lcm/ns/views/sol/lcm_op_occs_view.py b/lcm/ns/views/sol/lcm_op_occs_view.py index 94ccbcb8..09625333 100644 --- a/lcm/ns/views/sol/lcm_op_occs_view.py +++ b/lcm/ns/views/sol/lcm_op_occs_view.py @@ -81,9 +81,9 @@ class QueryMultiNsLcmOpOccs(APIView): logger.debug("QueryMultiNsLcmOpOccs--get::> Remove default fields if exclude_default is specified") if 'exclude_default' in list(request.query_params.keys()): for field in EXCLUDE_DEFAULT: - for lcm_op in ns_lcm_op_occs_serializer.data: + for lcm_op in resp_data: del lcm_op[field] - return Response(data=ns_lcm_op_occs_serializer.data, status=status.HTTP_200_OK) + return Response(data=resp_data, status=status.HTTP_200_OK) class QuerySingleNsLcmOpOcc(APIView): @@ -104,4 +104,4 @@ class QuerySingleNsLcmOpOcc(APIView): if not ns_lcm_op_occ_serializer.is_valid(): raise NSLCMException(ns_lcm_op_occ_serializer.errors) - return Response(data=ns_lcm_op_occ_serializer.data, status=status.HTTP_200_OK) + return Response(data=resp_data, status=status.HTTP_200_OK) diff --git a/lcm/ns/views/sol/ns_instances_views.py b/lcm/ns/views/sol/ns_instances_views.py index d45b90cd..e03aee00 100644 --- a/lcm/ns/views/sol/ns_instances_views.py +++ b/lcm/ns/views/sol/ns_instances_views.py @@ -50,7 +50,7 @@ class NSInstancesView(APIView): resp_serializer = NsInstanceSerializer(data=ret, many=True) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + return Response(data=ret, status=status.HTTP_200_OK) @swagger_auto_schema( request_body=CreateNsRequestSerializer(), @@ -89,7 +89,7 @@ class NSInstancesView(APIView): resp_serializer = NsInstanceSerializer(data=nsInstance) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - response = Response(data=resp_serializer.data, status=status.HTTP_201_CREATED) + response = Response(data=nsInstance, status=status.HTTP_201_CREATED) response["Location"] = NS_INSTANCE_BASE_URI % nsInstance['id'] return response @@ -115,7 +115,7 @@ class IndividualNsInstanceView(APIView): resp_serializer = NsInstanceSerializer(data=ret[0]) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + return Response(data=ret[0], status=status.HTTP_200_OK) @swagger_auto_schema( request_body=None, diff --git a/lcm/ns/views/sol/subscriptions_view.py b/lcm/ns/views/sol/subscriptions_view.py index c10e501d..b60f128c 100644 --- a/lcm/ns/views/sol/subscriptions_view.py +++ b/lcm/ns/views/sol/subscriptions_view.py @@ -95,7 +95,7 @@ class SubscriptionsView(APIView): data=subscription_data) if not sub_resp_serializer.is_valid(): raise NSLCMException(sub_resp_serializer.errors) - return Response(data=sub_resp_serializer.data, status=status.HTTP_201_CREATED) + return Response(data=subscription_data, status=status.HTTP_201_CREATED) @swagger_auto_schema( responses={ @@ -118,4 +118,4 @@ class SubscriptionsView(APIView): raise NSLCMException(subscriptions_serializer.errors) logger.debug("SubscribeNotification--get::> Remove default fields if exclude_default is " "specified") - return Response(data=subscriptions_serializer.data, status=status.HTTP_200_OK) + return Response(data=resp_data, status=status.HTTP_200_OK) diff --git a/lcm/ns_pnfs/views/pnf_view.py b/lcm/ns_pnfs/views/pnf_view.py index 72dddaf6..bea9a75d 100644 --- a/lcm/ns_pnfs/views/pnf_view.py +++ b/lcm/ns_pnfs/views/pnf_view.py @@ -70,7 +70,8 @@ class PnfView(APIView): else: pnfInstDataSet = GetPnf().do_biz() logger.debug("PnfView::get::ret=%s", pnfInstDataSet) - resp_serializer = PnfInstancesSerializer(data=[pnfInstData.__dict__ for pnfInstData in pnfInstDataSet]) + ret = [pnfInstData.__dict__ for pnfInstData in pnfInstDataSet] + resp_serializer = PnfInstancesSerializer(data=ret) if not resp_serializer.is_valid(): raise NSLCMException(resp_serializer.errors) return Response(data=resp_serializer.data, status=status.HTTP_200_OK) diff --git a/lcm/ns_sfcs/views/detail_views.py b/lcm/ns_sfcs/views/detail_views.py index e32831c0..3c5e9f8c 100644 --- a/lcm/ns_sfcs/views/detail_views.py +++ b/lcm/ns_sfcs/views/detail_views.py @@ -51,7 +51,7 @@ class SfcDetailView(APIView): return Response(data={'error': resp_serializer.errors}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - return Response(status=status.HTTP_200_OK, data=resp_serializer.data) + return Response(status=status.HTTP_200_OK, data=resp_data) @swagger_auto_schema( request_body=None, diff --git a/lcm/ns_vls/views/views.py b/lcm/ns_vls/views/views.py index ce8c3338..a18b30bd 100644 --- a/lcm/ns_vls/views/views.py +++ b/lcm/ns_vls/views/views.py @@ -71,16 +71,16 @@ class VlDetailView(APIView): if not vl_inst_info: return Response(status=status.HTTP_404_NOT_FOUND) - resp_serializer = GetVlRespSerializer(data={ - 'vlId': vl_inst_id, - 'vlName': vl_inst_info[0].vlinstancename, - 'vlStatus': "active"}) + ret = {'vlId': vl_inst_id, + 'vlName': vl_inst_info[0].vlinstancename, + 'vlStatus': "active"} + resp_serializer = GetVlRespSerializer(data=ret) if not resp_serializer.is_valid(): logger.error(resp_serializer.errors) return Response(data={'error': resp_serializer.errors}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - return Response(status=status.HTTP_200_OK, data=resp_serializer.data) + return Response(status=status.HTTP_200_OK, data=ret) @swagger_auto_schema( request_body=None, diff --git a/lcm/ns_vnfs/urls.py b/lcm/ns_vnfs/urls.py index 6b5b2597..4c6a93d7 100644 --- a/lcm/ns_vnfs/urls.py +++ b/lcm/ns_vnfs/urls.py @@ -28,9 +28,9 @@ urlpatterns = [ url(r'^api/nslcm/v1/ns/(?P<vnfmid>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', LcmNotify.as_view()), url(r'^api/nslcm/v1/ns/ns_vnfs/(?P<vnfinstid>[0-9a-zA-Z_-]+)/scaling$', NfScaleView.as_view()), url(r'^api/nslcm/v1/vnfonboarding$', NfVerifyView.as_view()), - url(r'^api/nslcm/v1/vnfms/(?P<vnfmid>[0-9a-zA-Z_-]+)', NfVnfmInfoView.as_view()), + url(r'^api/nslcm/v1/vnfms/(?P<vnfmid>[0-9a-zA-Z_-]+)$', NfVnfmInfoView.as_view()), # url(r'^api/nslcm/v1/vims/(?P<vimid>[0-9a-zA-Z_-]+)', NfVimInfoView.as_view()), - url(r'^api/nslcm/v1/vims/(?P<cloudowner>[0-9a-zA-Z_-]+)/(?P<cloudregionid>[0-9a-zA-Z_-]+)', NfVimInfoView.as_view()), + url(r'^api/nslcm/v1/vims/(?P<cloudowner>[0-9a-zA-Z_-]+)/(?P<cloudregionid>[0-9a-zA-Z_-]+)$', NfVimInfoView.as_view()), url(r'^api/nslcm/v2/grants$', VnfGrantView.as_view()), url(r'^api/nslcm/v2/ns/(?P<vnfmId>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', VnfNotifyView.as_view()), ] diff --git a/lcm/ns_vnfs/views/vnf_views.py b/lcm/ns_vnfs/views/vnf_views.py index c0264c39..cb303aa9 100644 --- a/lcm/ns_vnfs/views/vnf_views.py +++ b/lcm/ns_vnfs/views/vnf_views.py @@ -50,7 +50,7 @@ class VnfGrantView(APIView): resp_serializer = GrantSerializer(data=grant_resp) if not resp_serializer.is_valid(): - raise Exception(resp_serializer.errors) + raise Exception(grant_resp) return Response(data=grant_resp, status=status.HTTP_201_CREATED) except Exception as e: diff --git a/lcm/samples/views.py b/lcm/samples/views.py index a22b7b17..d0e22296 100644 --- a/lcm/samples/views.py +++ b/lcm/samples/views.py @@ -77,10 +77,11 @@ class TablesList(APIView): try: model_obj = eval("models.%s.objects" % modelName) count = len(model_obj.filter()) - resp_serializer = RecordCountSerializer(data={"count": count}) + ret = {"count": count} + resp_serializer = RecordCountSerializer(data=ret) if not resp_serializer.is_valid(): raise Exception(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + return Response(data=ret, status=status.HTTP_200_OK) except Exception as e: logger.error(e.args[0]) logger.error(traceback.format_exc()) |