diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-02-05 09:17:13 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2018-02-05 09:17:13 +0800 |
commit | 4c2ea45cc65e2fc2e7181fbff0edbf8454536ed1 (patch) | |
tree | ce900446f8a8e19b0023cc16495f84f4c2659d8c | |
parent | dbc8c50d764ebc6490cd4f94fd548c62eeba0dcb (diff) |
Refactor vfc-vnfres views file
Change-Id: I7cb441449be8570894e593683acf7c36c1294f75
Issue-ID: VFC-679
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | res/res/resources/views.py | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/res/res/resources/views.py b/res/res/resources/views.py index 743b3c1..b6b44a9 100644 --- a/res/res/resources/views.py +++ b/res/res/resources/views.py @@ -48,8 +48,7 @@ class getVnf(APIView): resp_data = fill_resp_data(vnf_inst[0]) vnf_info_serializer = VnfInfoSerializer(data=resp_data) - resp_isvalid = vnf_info_serializer.is_valid() - if not resp_isvalid: + if not vnf_info_serializer.is_valid(): raise Exception(vnf_info_serializer.errors) return Response( @@ -195,8 +194,7 @@ class getVnfs(APIView): arr.append(fill_resp_data(vnf_inst)) vnfs_info_serializer = VnfsInfoSerializer(data={'resp_data': arr}) - resp_isvalid = vnfs_info_serializer.is_valid() - if not resp_isvalid: + if not vnfs_info_serializer.is_valid(): raise Exception(vnfs_info_serializer.errors) return Response( @@ -231,8 +229,7 @@ class getVms(APIView): arr.append(fill_vms_data(vm)) vm_info_serializer = VmInfoSerializer(data={'resp_data': arr}) - resp_isvalid = vm_info_serializer.is_valid() - if not resp_isvalid: + if not vm_info_serializer.is_valid(): raise Exception(vm_info_serializer.errors) return Response( @@ -288,10 +285,8 @@ class getFlavors(APIView): for flavour in flavours: arr.append(fill_flavours_data(flavour)) - flavor_info_serializer = FlavorInfoSerializer( - data={'resp_data': arr}) - resp_isvalid = flavor_info_serializer.is_valid() - if not resp_isvalid: + flavor_info_serializer = FlavorInfoSerializer(data={'resp_data': arr}) + if not flavor_info_serializer.is_valid(): raise Exception(flavor_info_serializer.errors) return Response( @@ -341,10 +336,8 @@ class getNetworks(APIView): for network in networks: arr.append(fill_networks_data(network)) - network_info_serializer = NetworkInfoSerializer( - data={'resp_data': arr}) - resp_isvalid = network_info_serializer.is_valid() - if not resp_isvalid: + network_info_serializer = NetworkInfoSerializer(data={'resp_data': arr}) + if not network_info_serializer.is_valid(): raise Exception(network_info_serializer.errors) return Response( @@ -389,10 +382,8 @@ class getSubnets(APIView): arr = [] for subnet in subnets: arr.append(fill_subnets_data(subnet)) - subnet_info_serializer = SubnetInfoSerializer( - data={'resp_data': arr}) - resp_isvalid = subnet_info_serializer.is_valid() - if not resp_isvalid: + subnet_info_serializer = SubnetInfoSerializer(data={'resp_data': arr}) + if not subnet_info_serializer.is_valid(): raise Exception(subnet_info_serializer.errors) return Response( @@ -440,8 +431,7 @@ class getCps(APIView): for cp in cps: arr.append(fill_cps_data(cp)) cp_info_serializer = CpsInfoSerializer(data={'resp_data': arr}) - resp_isvalid = cp_info_serializer.is_valid() - if not resp_isvalid: + if not cp_info_serializer.is_valid(): raise Exception(cp_info_serializer.errors) return Response( @@ -488,8 +478,7 @@ class getVolumes(APIView): for v in volumes: arr.append(fill_volumes_data(v)) volume_serializer = VolumeInfoSerializer(data={'resp_data': arr}) - resp_isvalid = volume_serializer.is_valid() - if not resp_isvalid: + if not volume_serializer.is_valid(): raise Exception(volume_serializer.errors) return Response( |