1 # Copyright (c) 2019, 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
18 class VnfInstanceDataSerializer(serializers.Serializer):
19 vnfInstanceId = serializers.CharField(help_text="Identifier of the existing VNF instance to be used in"
20 "the NS. ", required=True)
21 vnfProfileId = serializers.CharField(help_text="Identifier of (Reference to) a vnfProfile defined in the "
22 "NSD which the existing VNF instance shall be matched "
23 "with. If not present", required=False, allow_null=True)
26 class ScaleNsByStepsDataSerializer(serializers.Serializer):
27 scalingDirection = serializers.ChoiceField(help_text="The scaling direction",
28 choices=["SCALE_IN", "SCALE_OUT"], required=True)
29 aspectId = serializers.CharField(help_text="The aspect of the NS that is requested to be scaled, as "
30 "declared in the NSD. ", required=True)
31 numberOfSteps = serializers.CharField(help_text="The number of scaling steps to be performed. Defaults "
32 "to 1. ", required=False, allow_null=True)
35 class NsScaleInfoSerializer(serializers.Serializer):
36 nsScalingAspectId = serializers.CharField(help_text="Identifier of the NS scaling aspect.", required=True)
37 nsScaleLevelId = serializers.CharField(help_text="Identifier of the NS scale level.", required=True)
40 class ScaleNsToLevelDataSerializer(serializers.Serializer):
41 nsInstantiationLevel = serializers.CharField(help_text="Identifier of the target NS instantiation level "
42 "of the current DF to which the NS instance is "
43 "requested to be scaled.",
44 required=False, allow_null=True)
45 nsScaleInfo = serializers.ListField(help_text="For each NS scaling aspect of the current DF",
46 child=NsScaleInfoSerializer(
47 help_text="This type represents the target NS Scale level for "
48 "each NS scaling aspect of the current deployment "
49 "flavour.", required=True),
50 required=False, allow_null=True)
53 class ParamsForVnfSerializer(serializers.Serializer):
54 vnfProfileId = serializers.CharField(help_text="Identifier of (reference to) a vnfProfile to which the "
55 "additional parameters apply.", required=True)
56 additionalParams = serializers.DictField(help_text="Additional parameters that are applied for the VNF "
57 "instance to be created.",
58 child=serializers.CharField(help_text="KeyValue Pairs",
60 required=False, allow_null=True)
63 class LocationConstraintsSerializer(serializers.Serializer):
64 countryCode = serializers.CharField(help_text="The two-letter ISO 3166 [29] country code in capital "
65 "letters", required=True)
66 civicAddressElement = serializers.ListField(help_text="Zero or more elements comprising the civic "
67 "address.", required=False, allow_null=True)
70 class VnfLocationConstraintSerializer(serializers.Serializer):
71 vnfProfileId = serializers.CharField(help_text="Identifier (reference to) of a VnfProfile in the NSD used "
72 "to manage the lifecycle of the VNF instance.",
75 locationConstraints = LocationConstraintsSerializer(help_text="This type represents location constraints "
76 "for a VNF to be instantiated. The location"
77 " constraints shall be presented as a "
78 "country code", required=True)
81 class ScaleNsDataSerializer(serializers.Serializer):
82 vnfInstanceToBeAdded = serializers.ListField(help_text="An existing VNF instance to be added to the NS "
83 "instance as part of the scaling operation. ",
84 child=VnfInstanceDataSerializer(
85 help_text="This type specifies an existing VNF instance "
86 "to be used in the NS instance and if needed",
87 required=True), required=False, allow_null=True)
88 vnfInstanceToBeRemoved = serializers.ListField(help_text="The VNF instance to be removed from the NS "
89 "instance as part of the scaling operation",
90 required=False, allow_null=True)
91 scaleNsByStepsData = ScaleNsByStepsDataSerializer(help_text="The information used to scale an NS "
92 "instance by one or more scaling steps",
93 required=False, allow_null=True)
94 scaleNsToLevelData = ScaleNsToLevelDataSerializer(help_text="The information used to scale an NS instance"
95 " to a target size. ",
96 required=False, allow_null=True)
97 additionalParamsForNs = serializers.DictField(help_text="Allows the OSS/BSS to provide additional "
98 "parameter(s) at the NS level necessary for the "
100 child=serializers.CharField(help_text="KeyValue Pairs",
102 required=False, allow_null=True)
103 additionalParamsForVnf = serializers.ListField(help_text="Allows the OSS/BSS to provide additional "
104 "parameter(s) per VNF instance",
105 child=ParamsForVnfSerializer(
106 help_text="This type defines the additional parameters"
107 " for the VNF instance to be created "
108 "associated with an NS instance.",
109 required=True), required=False, allow_null=True)
110 locationConstraints = serializers.ListField(help_text="The location constraints for the VNF to be "
111 "instantiated as part of the NS scaling.",
112 child=VnfLocationConstraintSerializer(
113 help_text="This type represents the association of "
114 "location constraints to a VNF instance to"
115 "be created according to a specific VNF "
116 "profile", required=True),
117 required=False, allow_null=True)
120 class VnfScaleInfoSerializer(serializers.Serializer):
121 aspectlId = serializers.Serializer(help_text="The scaling aspect", required=True)
122 scaleLevel = serializers.Serializer(help_text="The scale level for that aspect", required=True)
125 class ScaleToLevelDataSerializer(serializers.Serializer):
126 vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the target instantiation level "
127 "of the current deployment flavour to which "
128 "the VNF is requested to be scaled.",
129 required=False, allow_null=True)
130 vnfScaleInfo = serializers.ListField(help_text="For each scaling aspect of the current deployment "
132 child=VnfScaleInfoSerializer(help_text="This type describes the "
133 "provides information about"
134 " the scale level of a VNF"
135 " instance with respect to "
136 "one scaling aspect",
138 required=False, allow_null=True)
140 additionalParams = serializers.DictField(help_text="Additional parameters passed by the NFVO as input to "
141 "the scaling process", required=False, allow_null=True)
144 class ScaleByStepDataSerializer(serializers.Serializer):
145 aspectId = serializers.CharField(help_text="Identifier of (reference to) the aspect of the VNF that is "
146 "requested to be scaled", required=True)
147 numberOfSteps = serializers.CharField(help_text="Number of scaling steps.",
148 required=False, allow_null=True)
149 additionalParams = serializers.DictField(help_text="Additional parameters passed by the NFVO as input to"
150 "he scaling process", required=False, allow_null=True)
153 class ScaleVnfDataSerializer(serializers.Serializer):
154 vnfInstanceid = serializers.CharField(help_text="Identifier of the VNF instance being scaled.",
157 scaleVnfType = serializers.ChoiceField(help_text="Type of the scale VNF operation requested.",
158 choices=["SCALE_OUT", "SCALE_IN", "SCALE_TO_INSTANTIATION_LEVEL",
159 "SCALE_TO_SCALE_LEVEL(S)"], required=True)
161 scaleToLevelData = ScaleToLevelDataSerializer(help_text="The information used for scaling to a "
162 "given level.", required=False)
164 scaleByStepData = ScaleByStepDataSerializer(help_text="The information used for scaling by steps",
168 class ScaleNsRequestSerializer(serializers.Serializer):
169 scaleType = serializers.ChoiceField(help_text="Indicates the type of scaling to be performed",
170 choices=["SCALE_NS ", "SCALE_VNF"], required=True)
171 scaleNsData = ScaleNsDataSerializer(help_text="The necessary information to scale the referenced NS "
172 "instance. ", required=False, allow_null=True)
173 scaleVnfData = serializers.ListField(help_text="Timestamp indicating the scale time of the NS",
174 child=ScaleVnfDataSerializer(help_text="This type represents defines"
175 "the information to scale a "
176 "VNF instance to a given "
177 "level", required=True),
178 required=False, allow_null=True)
179 scaleTime = serializers.CharField(help_text="Timestamp indicating the scale time of the NS",
180 required=False, allow_null=True)