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