Modify vnf query related stuffs in vnflcm. 13/59613/1
authorlaili <lai.li@zte.com.cn>
Wed, 8 Aug 2018 07:51:04 +0000 (15:51 +0800)
committerlaili <lai.li@zte.com.cn>
Wed, 8 Aug 2018 07:51:22 +0000 (15:51 +0800)
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 <lai.li@zte.com.cn>
lcm/lcm/nf/serializers/instantiated_vnf_info.py
lcm/lcm/nf/serializers/scale_info.py
lcm/lcm/nf/serializers/virtual_storage_resource_info.py
lcm/lcm/nf/serializers/vnf_instance.py
lcm/lcm/nf/serializers/vnf_instances.py [new file with mode: 0644]
lcm/lcm/nf/serializers/vnfc_resource_info.py

index 1324b9b..82c2ec5 100644 (file)
@@ -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)
index a97d42c..08372e7 100644 (file)
@@ -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)
index 5c864f9..8ec23a3 100644 (file)
@@ -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,
index bfcbd29..bd45362 100644 (file)
@@ -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 (file)
index 0000000..f313290
--- /dev/null
@@ -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()
index 2c6c4f1..3ad0c6f 100644 (file)
@@ -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,