1 # Copyright (c) 2018, CMCC Technologies Co., Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rest_framework import serializers
17 from lcm.ns.serializers.pub_serializers import IpOverEthernetAddressDataSerializer
18 from lcm.ns.serializers.update_serializers import AddPnfDataSerializer, VnfInstanceDataSerializer
21 class CpProtocolDataSerializer(serializers.Serializer):
22 layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
23 choices=["IP_OVER_ETHERNET"], required=True)
24 ipOverEthernet = IpOverEthernetAddressDataSerializer(help_text="Network address data for IP over Ethernet"
25 "to assign to the extCP instance.",
26 required=False, allow_null=True)
29 class SapDataSerializer(serializers.Serializer):
30 sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
31 sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
32 description = serializers.CharField(help_text="Human readable description for the SAP.", required=True)
33 sapProtocolData = CpProtocolDataSerializer(help_text="Parameters for configuring the network protocols"
35 required=False, allow_null=True, many=True)
38 class civicAddressElementSerializer(serializers.Serializer):
39 caType = serializers.CharField(help_text="Describe the content type of caValue.", required=True)
40 caValue = serializers.CharField(help_text="Content of civic address element corresponding to the"
41 "aType.", required=True)
44 class LocationConstraintsSerializer(serializers.Serializer):
45 countryCode = serializers.CharField(help_text="The two-letter ISO 3166 [29] country code in capital"
46 "letters.", required=True)
47 civicAddressElement = civicAddressElementSerializer(help_text="Zero or more elements comprising the civic"
49 required=False, allow_null=True, many=True)
52 class VnfLocationConstraintSerializer(serializers.Serializer):
53 vnfProfileId = serializers.CharField(help_text="ID of VNF profile", required=False, allow_null=True)
54 locationConstraints = LocationConstraintsSerializer(help_text="Defines the location constraints for the"
55 "VNF instance to be created based on the"
57 required=False, allow_null=True)
60 class ParamsForVnfSerializer(serializers.Serializer):
61 vnfProfileId = serializers.CharField(help_text="Identifier of (reference to) a vnfProfile to which the"
62 "additional parameters apply", required=True)
63 additionalParams = serializers.DictField(help_text="Content of civic address element corresponding to the"
65 child=serializers.CharField(help_text="KeyValue Pairs",
67 required=False, allow_null=True)
70 class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
71 vnfdId = serializers.ListField(help_text="Reference to a VNFD.", required=False, allow_null=True)
72 vnfProfileId = serializers.ListField(help_text="Reference to a vnfProfile defined in the NSD.",
74 vnfInstanceId = serializers.ListField(help_text="Reference to the existing VNF instance as the subject of"
75 "the affinity or anti-affinity rule.",
76 required=False, allow_null=True)
77 affinityOrAntiAffiinty = serializers.ChoiceField(help_text="The type of the constraint.",
78 choices=["AFFINITY", "ANTI_AFFINITY"], required=True)
79 scope = serializers.ChoiceField(help_text="Specifies the scope of the rule where the placement constraint"
80 "applies.", choices=["NFVI_POP", "ZONE", "ZONE_GROUP",
81 "NFVI_NODE"], required=True)
84 class InstantNsReqSerializer(serializers.Serializer):
85 nsFlavourId = serializers.CharField(help_text="Identifier of the NS deployment flavour to be"
86 "instantiated.", required=True)
87 sapData = SapDataSerializer(help_text="Create data concerning the SAPs of this NS",
88 required=False, allow_null=True, many=True)
89 addpnfData = AddPnfDataSerializer(help_text="Information on the PNF(s) that are part of this NS.",
90 required=False, allow_null=True, many=True)
91 vnfInstanceData = VnfInstanceDataSerializer(help_text="Specify an existing VNF instance to be used in "
93 required=False, allow_null=True, many=True)
94 nestedNsInstanceId = serializers.ListField(help_text="Specify an existing NS instance to be used as a "
95 "nested NS within the NS",
96 required=False, allow_null=True)
97 localizationLanguage = VnfLocationConstraintSerializer(help_text="Defines the location constraints for "
98 "the VNF to be instantiated as part of"
99 " the NS instantiation.",
100 required=False, allow_null=True, many=True)
101 additionalParamForNs = serializers.DictField(
102 help_text="Allows the OSS/BSS to provide additional parameters at the NS level ",
103 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
107 additionalParamsForVnf = ParamsForVnfSerializer(help_text="Allows the OSS/BSS to provide additional "
108 "parameter(s)per VNF instance",
109 required=False, allow_null=True, many=True)
110 startTime = serializers.DateTimeField(help_text="Timestamp indicating the earliest time to instantiate"
111 "the NS.", required=False, allow_null=True)
112 nsInstantiationLevelId = serializers.CharField(help_text="Identifies one of the NS instantiation levels"
113 "declared in the DF applicable to this NS "
114 "instance", required=False, allow_null=True)
115 additionalAffinityOrAntiAffiniityRule = AffinityOrAntiAffinityRuleSerializer(
116 help_text="Specifies additional affinity or anti-affinity constraint for the VNF instances to be"
117 " instantiated as part of the NS instantiation.",
118 required=False, allow_null=True, many=True)
121 class InstNsPostDealReqSerializer(serializers.Serializer):
122 status = serializers.CharField(help_text="Status of NS Inst", required=True)