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
17 from lcm.ns.serializers.sol.inst_ns_serializers import VnfLocationConstraintSerializer, ParamsForVnfSerializer
18 from lcm.ns.serializers.sol.update_serializers import VnfInstanceDataSerializer
19 from lcm.ns.serializers.sol.ns_instance import NsScaleInfoSerializer, VnfScaleInfoSerializer
22 # class VnfInstanceDataSerializer(serializers.Serializer):
23 # vnfInstanceId = serializers.CharField(help_text="Identifier of the existing VNF instance to be used in"
24 # "the NS. ", required=True)
25 # vnfProfileId = serializers.CharField(help_text="Identifier of (Reference to) a vnfProfile defined in the "
26 # "NSD which the existing VNF instance shall be matched "
27 # "with. If not present", required=False, allow_null=True)
30 class ScaleNsByStepsDataSerializer(serializers.Serializer):
31 scalingDirection = serializers.ChoiceField(
32 help_text="The scaling direction",
33 choices=["SCALE_IN", "SCALE_OUT"],
35 aspectId = serializers.CharField(
36 help_text="The aspect of the NS that is requested to be scaled, as declared in the NSD. ",
38 numberOfSteps = serializers.CharField(
39 help_text="The number of scaling steps to be performed. Defaults to 1. ",
44 class ScaleNsToLevelDataSerializer(serializers.Serializer):
45 nsInstantiationLevel = serializers.CharField(
46 help_text="Identifier of the target NS instantiation level "
47 "of the current DF to which the NS instance is requested to be scaled.",
50 nsScaleInfo = serializers.ListField(
51 help_text="For each NS scaling aspect of the current DF",
52 child=NsScaleInfoSerializer(
53 help_text="This type represents the target NS Scale level for "
54 "each NS scaling aspect of the current deployment flavour.",
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="Additional parameters that are applied for the VNF "
64 # "instance to be created.",
65 # child=serializers.CharField(help_text="KeyValue Pairs",
67 # required=False, allow_null=True)
70 # class LocationConstraintsSerializer(serializers.Serializer):
71 # countryCode = serializers.CharField(help_text="The two-letter ISO 3166 [29] country code in capital "
72 # "letters", required=True)
73 # civicAddressElement = serializers.ListField(help_text="Zero or more elements comprising the civic "
74 # "address.", required=False, allow_null=True)
77 # class VnfLocationConstraintSerializer(serializers.Serializer):
78 # vnfProfileId = serializers.CharField(help_text="Identifier (reference to) of a VnfProfile in the NSD used "
79 # "to manage the lifecycle of the VNF instance.",
82 # locationConstraints = LocationConstraintsSerializer(help_text="This type represents location constraints "
83 # "for a VNF to be instantiated. The location"
84 # " constraints shall be presented as a "
85 # "country code", required=True)
88 class ScaleNsDataSerializer(serializers.Serializer):
89 vnfInstanceToBeAdded = serializers.ListField(
90 help_text="An existing VNF instance to be added to the NS instance as part of the scaling operation.",
91 child=VnfInstanceDataSerializer(
92 help_text="This type specifies an existing VNF instance to be used in the NS instance and if needed",
96 vnfInstanceToBeRemoved = serializers.ListField(
97 help_text="The VNF instance to be removed from the NS instance as part of the scaling operation",
100 scaleNsByStepsData = ScaleNsByStepsDataSerializer(
101 help_text="The information used to scale an NS instance by one or more scaling steps",
104 scaleNsToLevelData = ScaleNsToLevelDataSerializer(
105 help_text="The information used to scale an NS instance to a target size. ",
108 additionalParamsForNs = serializers.DictField(
109 help_text="Allows the OSS/BSS to provide additional parameter(s) at the NS level necessary for the NS scaling ",
110 child=serializers.CharField(help_text="KeyValue Pairs",
114 additionalParamsForVnf = serializers.ListField(
115 help_text="Allows the OSS/BSS to provide additional parameter(s) per VNF instance",
116 child=ParamsForVnfSerializer(
117 help_text="This type defines the additional parameters for the VNF instance to be created associated with an NS instance.",
121 locationConstraints = serializers.ListField(
122 help_text="The location constraints for the VNF to be instantiated as part of the NS scaling.",
123 child=VnfLocationConstraintSerializer(
124 help_text="This type represents the association of location constraints to a VNF instance to"
125 "be created according to a specific VNF profile",
131 class ScaleToLevelDataSerializer(serializers.Serializer):
132 vnfInstantiationLevelId = serializers.CharField(
133 help_text="Identifier of the target instantiation level of the current deployment flavour to which the VNF is requested to be scaled.",
136 vnfScaleInfo = serializers.ListField(
137 help_text="For each scaling aspect of the current deployment flavour",
138 child=VnfScaleInfoSerializer(
139 help_text="This type describes the provides information about the scale level of a VNF instance with respect to one scaling aspect",
143 additionalParams = serializers.DictField(
144 help_text="Additional parameters passed by the NFVO as input to the scaling process",
149 class ScaleByStepDataSerializer(serializers.Serializer):
150 aspectId = serializers.CharField(
151 help_text="Identifier of (reference to) the aspect of the VNF that is requested to be scaled.",
153 numberOfSteps = serializers.CharField(
154 help_text="Number of scaling steps.",
157 additionalParams = serializers.DictField(
158 help_text="Additional parameters passed by the NFVO as input to the scaling process.",
163 class ScaleVnfDataSerializer(serializers.Serializer):
164 vnfInstanceid = serializers.CharField(
165 help_text="Identifier of the VNF instance being scaled.",
168 scaleVnfType = serializers.ChoiceField(
169 help_text="Type of the scale VNF operation requested.",
170 choices=["SCALE_OUT", "SCALE_IN", "SCALE_TO_INSTANTIATION_LEVEL", "SCALE_TO_SCALE_LEVEL(S)"],
173 scaleToLevelData = ScaleToLevelDataSerializer(
174 help_text="The information used for scaling to a given level.",
177 scaleByStepData = ScaleByStepDataSerializer(
178 help_text="The information used for scaling by steps.",
182 class ScaleNsRequestSerializer(serializers.Serializer):
183 scaleType = serializers.ChoiceField(
184 help_text="Indicates the type of scaling to be performed",
185 choices=["SCALE_NS", "SCALE_VNF"],
187 scaleNsData = ScaleNsDataSerializer(
188 help_text="The necessary information to scale the referenced NS instance.",
191 scaleVnfData = serializers.ListField(
192 help_text="Timestamp indicating the scale time of the NS",
193 child=ScaleVnfDataSerializer(
194 help_text="This type represents defines the information to scale a VNF instance to a given level",
198 scaleTime = serializers.CharField(
199 help_text="Timestamp indicating the scale time of the NS",
204 # class ManualScaleNsReqSerializer(serializers.Serializer):
205 # scaleType = serializers.CharField(
206 # help_text="Type of NS Scale",
208 # scaleNsData = ScaleNsDataSerializer(
209 # help_text="Scale NS data",