Add Placement Constraint serializer 95/34195/2
authorfujinhua <fu.jinhua@zte.com.cn>
Tue, 6 Mar 2018 03:36:54 +0000 (11:36 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Tue, 6 Mar 2018 03:47:16 +0000 (11:47 +0800)
Change-Id: I21f7130b536f0e17776c057a4861ef82c6d932bb
Issue-ID: VFC-779
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/v2/serializers.py

index a2eae1b..69721cd 100644 (file)
@@ -69,6 +69,47 @@ class ResourceDefinitionSerializer(serializers.Serializer):
     )
 
 
+class ConstraintResourceRefSerializer(serializers.Serializer):
+    idType = serializers.ChoiceField(
+        help_text="The type of the identifier.",
+        choices=["RES_MGMT", "GRANT"],
+        required=True
+    )
+    resourceId = serializers.CharField(
+        help_text="An actual resource-management-level identifier(idType=RES_MGMT), or an identifier that references a ResourceDefinition(idType=GRANT).",
+        required=True
+    )
+    vimConnectionId = serializers.CharField(
+        help_text="",
+        required=False,
+        allow_null=True,
+        allow_blank=True
+    )
+    resourceProviderId = serializers.CharField(
+        help_text="Identifier of the resource provider. It shall only be present when idType = RES_MGMT.",
+        required=False,
+        allow_null=True,
+        allow_blank=True
+    )
+
+
+class PlacementConstraintSerializer(serializers.Serializer):
+    affinityOrAntiAffinity = serializers.ChoiceField(
+        help_text="The type of the constraint.",
+        choices=["AFFINITY", "ANTI_AFFINITY"],
+        required=True
+    )
+    scope = serializers.ChoiceField(
+        help_text="The scope of the placement constraint indicating the category of the place where the constraint applies.",
+        choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"],
+        required=True
+    )
+    resource = ConstraintResourceRefSerializer(
+        help_text="References to resources in the constraint rule.",
+        many=True
+    )
+
+
 class GrantRequestSerializer(serializers.Serializer):
     vnfInstanceId = serializers.CharField(
         help_text="Identifier of the VNF instance which this grant request is related to.",
@@ -123,6 +164,10 @@ class GrantRequestSerializer(serializers.Serializer):
         help_text="Provides the definitions of resources to be modified by the LCM operation.",
         many=True
     )
+    placementConstraints = PlacementConstraintSerializer(
+        help_text="Placement constraints that the VNFM may send to the NFVO in order to influence the resource placement decision.",
+        many=True
+    )
 
 
 class VimConnectionInfoSerializer(serializers.Serializer):