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