From 8b1e127692f5d3443938bd8d91365424fee46cdc Mon Sep 17 00:00:00 2001 From: laili Date: Wed, 8 Aug 2018 15:51:04 +0800 Subject: Modify vnf query related stuffs in vnflcm. Remove useless 'allow_blank' sentences. Change improper 'require' value, 'allow_null' value, and serializertype. Add vnf_instances.py for multiple vnf instance serialization. Change-Id: I483934d9e90b98dfeb881057cb7bc1bfe0bbc3f3 Issue-ID: VFC-1016 Signed-off-by: laili --- lcm/lcm/nf/serializers/instantiated_vnf_info.py | 13 ++++----- lcm/lcm/nf/serializers/scale_info.py | 3 +- .../serializers/virtual_storage_resource_info.py | 6 ++-- lcm/lcm/nf/serializers/vnf_instance.py | 32 +++++++++++----------- lcm/lcm/nf/serializers/vnf_instances.py | 17 ++++++++++++ lcm/lcm/nf/serializers/vnfc_resource_info.py | 8 ++---- 6 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 lcm/lcm/nf/serializers/vnf_instances.py (limited to 'lcm') diff --git a/lcm/lcm/nf/serializers/instantiated_vnf_info.py b/lcm/lcm/nf/serializers/instantiated_vnf_info.py index 1324b9b0..82c2ec5b 100644 --- a/lcm/lcm/nf/serializers/instantiated_vnf_info.py +++ b/lcm/lcm/nf/serializers/instantiated_vnf_info.py @@ -28,13 +28,13 @@ class InstantiatedVnfInfoSerializer(serializers.Serializer): help_text="Identifier of the VNF deployment flavour applied to this VNF instance.", max_length=255, required=True, - allow_null=False, + allow_null=True, allow_blank=False) vnfState = serializers.ChoiceField( help_text="State of the VNF instance.", choices=["STARTED", "STOPPED"], required=True, - allow_null=False, + allow_null=True, allow_blank=False) scaleStatus = ScaleInfoSerializer( help_text="Scale status of the VNF, one entry per aspect. \ @@ -72,17 +72,14 @@ class InstantiatedVnfInfoSerializer(serializers.Serializer): help_text="Information about the virtualised compute and storage resources used by the VNFCs of the VNF instance.", many=True, required=False, - allow_null=True, - allow_blank=True) + allow_null=True) vnfVirtualLinkResourceInfo = VnfVirtualLinkResourceInfoSerializer( help_text="Information about the virtualised network resources used by the VLs of the VNF instance.", many=True, required=False, - allow_null=True, - allow_blank=True) + allow_null=True) virtualStorageResourceInfo = VirtualStorageResourceInfoSerializer( help_text="Information about the virtualised storage resources used as storage for the VNF instance.", many=True, required=False, - allow_null=True, - allow_blank=True) + allow_null=True) diff --git a/lcm/lcm/nf/serializers/scale_info.py b/lcm/lcm/nf/serializers/scale_info.py index a97d42c2..08372e73 100644 --- a/lcm/lcm/nf/serializers/scale_info.py +++ b/lcm/lcm/nf/serializers/scale_info.py @@ -26,5 +26,4 @@ class ScaleInfoSerializer(serializers.Serializer): help_text="Indicates the scale level. \ The minimum value shall be 0 and the maximum value shall be <= maxScaleLevel as described in the VNFD.", required=True, - allow_null=False, - allow_blank=False) + allow_null=False) diff --git a/lcm/lcm/nf/serializers/virtual_storage_resource_info.py b/lcm/lcm/nf/serializers/virtual_storage_resource_info.py index 5c864f9b..8ec23a37 100644 --- a/lcm/lcm/nf/serializers/virtual_storage_resource_info.py +++ b/lcm/lcm/nf/serializers/virtual_storage_resource_info.py @@ -27,9 +27,9 @@ class VirtualStorageResourceInfoSerializer(serializers.Serializer): virtualStorageDescId = serializers.CharField( help_text="Identifier of the VirtualStorageDesc in the VNFD.", max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=False, + allow_null=True, + allow_blank=True) storageResource = ResourceHandleSerializer( help_text="Reference to the VirtualStorage resource.", required=True, diff --git a/lcm/lcm/nf/serializers/vnf_instance.py b/lcm/lcm/nf/serializers/vnf_instance.py index bfcbd298..bd453629 100644 --- a/lcm/lcm/nf/serializers/vnf_instance.py +++ b/lcm/lcm/nf/serializers/vnf_instance.py @@ -43,43 +43,43 @@ class VnfInstanceSerializer(serializers.Serializer): vnfdId = serializers.CharField( help_text="Identifier of the VNFD on which the VNF instance is based.", max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=False, + allow_null=True, + allow_blank=True) vnfProvider = serializers.CharField( help_text="Provider of the VNF and the VNFD. \ The value is copied from the VNFD. ", max_length=255, required=True, - allow_null=False, + allow_null=True, allow_blank=False) vnfProductName = serializers.CharField( help_text="Name to identify the VNF Product. \ The value is copied from the VNFD.", max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=False, + allow_null=True, + allow_blank=True) vnfSoftwareVersion = serializers.CharField( help_text="Software version of the VNF. \ The value is copied from the VNFD.", max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=False, + allow_null=True, + allow_blank=True) vnfdVersion = serializers.CharField( help_text="Identifies the version of the VNFD. \ The value is copied from the VNFD.", max_length=255, required=True, - allow_null=False, + allow_null=True, allow_blank=False) vnfPkgId = serializers.CharField( help_text="Identifier of information held by the NFVO about the specific VNF package on which the VNF is based. \ This attribute can be modified with the PATCH method.", max_length=255, required=True, - allow_null=False, + allow_null=True, allow_blank=False) vnfConfigurableProperties = serializers.DictField( help_text="Current values of the configurable properties of the VNF instance. \ @@ -95,9 +95,9 @@ class VnfInstanceSerializer(serializers.Serializer): instantiationState = serializers.ChoiceField( help_text="The instantiation state of the VNF.", choices=["NOT_INSTANTIATED", "INSTANTIATED"], - required=True, - allow_null=False, - allow_blank=False) + required=False, + allow_null=True, + allow_blank=True) instantiatedVnfInfo = InstantiatedVnfInfoSerializer( help_text="Information specific to an instantiated VNF instance. \ This attribute shall be present if the instantiateState attribute value is INSTANTIATED", @@ -117,5 +117,5 @@ class VnfInstanceSerializer(serializers.Serializer): allow_null=True) _links = _LinksSerializer( help_text="Links to resources related to this resource.", - required=True, + required=False, allow_null=False) diff --git a/lcm/lcm/nf/serializers/vnf_instances.py b/lcm/lcm/nf/serializers/vnf_instances.py new file mode 100644 index 00000000..f3132904 --- /dev/null +++ b/lcm/lcm/nf/serializers/vnf_instances.py @@ -0,0 +1,17 @@ +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from rest_framework import serializers +from vnf_instance import VnfInstanceSerializer + + +class VnfInstancesSerializer(serializers.ListSerializer): + child = VnfInstanceSerializer() diff --git a/lcm/lcm/nf/serializers/vnfc_resource_info.py b/lcm/lcm/nf/serializers/vnfc_resource_info.py index 2c6c4f19..3ad0c6f5 100644 --- a/lcm/lcm/nf/serializers/vnfc_resource_info.py +++ b/lcm/lcm/nf/serializers/vnfc_resource_info.py @@ -33,14 +33,12 @@ class VnfcResourceInfoSerializer(serializers.Serializer): help_text="Reference to the VirtualCompute resource.", required=True, allow_null=False) - storageResourceIds = serializers.CharField( + storageResourceIds = serializers.ListSerializer( help_text="References to the VirtualStorage resources. \ The value refers to a VirtualStorageResourceInfo item in the VnfInstance.", - max_length=255, - many=True, + child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True), required=False, - allow_null=True, - allow_blank=True) + allow_null=True) reservationId = serializers.CharField( help_text="The reservation identifier applicable to the resource.", max_length=255, -- cgit 1.2.3-korg