diff options
Diffstat (limited to 'res')
-rw-r--r-- | res/res/resources/serializers.py | 6 | ||||
-rw-r--r-- | res/res/resources/views.py | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/res/res/resources/serializers.py b/res/res/resources/serializers.py index 65d9920..31fb2f4 100644 --- a/res/res/resources/serializers.py +++ b/res/res/resources/serializers.py @@ -128,14 +128,12 @@ class instantiatedVnfInfoSerializer(serializers.Serializer): flavourId = serializers.CharField(help_text="flavour Id", required=True, allow_null=True) vnfState = serializers.ChoiceField(help_text="vnf State", choices=['STARTED', 'STOPPED'], required=True, allow_null=True) localizationLanguage = serializers.CharField(help_text="localizationLanguage", required=True, allow_null=True) - metadata = serializers.CharField(help_text="metadata", required=True, allow_null=True) - extensions = serializers.CharField(help_text="extensions", required=True, allow_null=True) scaleStatus = ScaleInfoSerializer(help_text="scaleStatus", many=True) extCpInfo = extCpInfoSerializer(help_text="extCpInfo", many=True) extVirtualLink = ExtVirtualLinkInfoSerializer(help_text="extVirtualLink", many=True) monitoringParameters = monitoringParametersSerializer(help_text="monitoringParameters", allow_null=True) vmInfo = VmResponseSerializer(help_text="vmInfo", many=True, allow_null=True) - vimInfo = vimInfoSerializer(help_text="vimInfo", many=True, allow_null=True) + vimInfo = vimInfoSerializer(help_text="vimInfo", many=True, required=False, allow_null=True) vnfcResourceInfo = vnfcResourceInfoSerializer(help_text="vnfcResourceInfo", many=True) virtualLinkResourceInfo = virtualLinkResourceInfoSerializer(help_text="virtualLinkResourceInfo", many=True) virtualStorageResourceInfo = virtualStorageResourceInfoSerializer(help_text="virtualStorageResourceInfo", many=True) @@ -153,6 +151,8 @@ class VnfInfoSerializer(serializers.Serializer): vnfProductName = serializers.CharField(help_text="vnfProductName", required=False, allow_null=True) vnfConfigurableProperties = serializers.CharField(help_text="vnfConfigurableProperties", required=False, allow_null=True) instantiationState = serializers.CharField(help_text="instantiationState", required=False, allow_null=True) + extensions = serializers.CharField(help_text="extensions", required=False, allow_null=True) + metadata = serializers.CharField(help_text="metadata", required=False, allow_null=True) instantiatedVnfInfo = instantiatedVnfInfoSerializer(help_text="instantiatedVnfInfo", required=True) diff --git a/res/res/resources/views.py b/res/res/resources/views.py index 582a1d4..dc0026a 100644 --- a/res/res/resources/views.py +++ b/res/res/resources/views.py @@ -44,7 +44,13 @@ class getVnfs(APIView): if not vnf_inst: return Response(data={'error': 'Vnf(%s) does not exist' % vnfInstanceId}, status=status.HTTP_404_NOT_FOUND) resp_data = fill_resp_data(vnf_inst[0]) - return Response(data=resp_data, status=status.HTTP_200_OK) + + vnfInfoSerializer = VnfInfoSerializer(data=resp_data) + isValid = vnfInfoSerializer.is_valid() + if not isValid: + raise Exception(vnfInfoSerializer.errors) + + return Response(data=vnfInfoSerializer.data, status=status.HTTP_200_OK) except Exception as e: logger.error(e.message) logger.error(traceback.format_exc()) |