b993ed2ddc26e0699588cdc9574d8ee051b95b65
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / scale_ns_serializers.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2
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
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
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.
14
15 from rest_framework import serializers
16
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
20
21
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)
28
29
30 class ScaleNsByStepsDataSerializer(serializers.Serializer):
31     scalingDirection = serializers.ChoiceField(
32         help_text="The scaling direction",
33         choices=["SCALE_IN", "SCALE_OUT"],
34         required=True)
35     aspectId = serializers.CharField(
36         help_text="The aspect of the NS that is requested to be scaled, as declared in the NSD. ",
37         required=True)
38     numberOfSteps = serializers.CharField(
39         help_text="The number of scaling steps to be performed. Defaults to 1. ",
40         required=False,
41         allow_null=True)
42
43
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.",
48         required=False,
49         allow_null=True)
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.",
55             required=True),
56         required=False,
57         allow_null=True)
58
59
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",
66 #                                                                          allow_blank=True),
67 #                                              required=False, allow_null=True)
68
69
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)
75
76
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.",
80 #                                          required=True)
81 #
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)
86
87
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",
93             required=True),
94         required=False,
95         allow_null=True)
96     vnfInstanceToBeRemoved = serializers.ListField(
97         help_text="The VNF instance to be removed from the NS instance as part of the scaling operation",
98         required=False,
99         allow_null=True)
100     scaleNsByStepsData = ScaleNsByStepsDataSerializer(
101         help_text="The information used to scale an NS instance by one or more scaling steps",
102         required=False,
103         allow_null=True)
104     scaleNsToLevelData = ScaleNsToLevelDataSerializer(
105         help_text="The information used to scale an NS instance to a target size. ",
106         required=False,
107         allow_null=True)
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",
111                                     allow_blank=True),
112         required=False,
113         allow_null=True)
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.",
118             required=True),
119         required=False,
120         allow_null=True)
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",
126             required=True),
127         required=False,
128         allow_null=True)
129
130
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.",
134         required=False,
135         allow_null=True)
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",
140             required=True),
141         required=False,
142         allow_null=True)
143     additionalParams = serializers.DictField(
144         help_text="Additional parameters passed by the NFVO as input to the scaling process",
145         required=False,
146         allow_null=True)
147
148
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.",
152         required=True)
153     numberOfSteps = serializers.CharField(
154         help_text="Number of scaling steps.",
155         required=False,
156         allow_null=True)
157     additionalParams = serializers.DictField(
158         help_text="Additional parameters passed by the NFVO as input to the scaling process.",
159         required=False,
160         allow_null=True)
161
162
163 class ScaleVnfDataSerializer(serializers.Serializer):
164     vnfInstanceid = serializers.CharField(
165         help_text="Identifier of the VNF instance being scaled.",
166         required=True)
167
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)"],
171         required=True)
172
173     scaleToLevelData = ScaleToLevelDataSerializer(
174         help_text="The information used for scaling to a given level.",
175         required=False)
176
177     scaleByStepData = ScaleByStepDataSerializer(
178         help_text="The information used for scaling by steps.",
179         required=False)
180
181
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"],
186         required=True)
187     scaleNsData = ScaleNsDataSerializer(
188         help_text="The necessary information to scale the referenced NS instance.",
189         required=False,
190         allow_null=True)
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",
195             required=True),
196         required=False,
197         allow_null=True)
198     scaleTime = serializers.CharField(
199         help_text="Timestamp indicating the scale time of the NS",
200         required=False,
201         allow_null=True)
202
203
204 # class ManualScaleNsReqSerializer(serializers.Serializer):
205 #    scaleType = serializers.CharField(
206 #        help_text="Type of NS Scale",
207 #        required=True)
208 #    scaleNsData = ScaleNsDataSerializer(
209 #        help_text="Scale NS data",
210 #        many=True)