update link to upper-constraints.txt
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / scale_ns_serializers.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2 # Copyright (c) 2019, ZTE Corporation.
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from rest_framework import serializers
17
18 from lcm.ns.serializers.sol.inst_ns_serializers import VnfLocationConstraintSerializer, ParamsForVnfSerializer
19 from lcm.ns.serializers.sol.update_serializers import VnfInstanceDataSerializer
20 from lcm.ns.serializers.sol.ns_instance import NsScaleInfoSerializer, VnfScaleInfoSerializer
21 from lcm.ns.enum import SCALING_DIRECTION, SCALE_VNF_TYPE, SCALE_TYPE
22 from lcm.pub.utils.enumutil import enum_to_list
23
24
25 class ScaleNsByStepsDataSerializer(serializers.Serializer):
26     scalingDirection = serializers.ChoiceField(
27         help_text="The scaling direction",
28         choices=enum_to_list(SCALING_DIRECTION),
29         required=True)
30     aspectId = serializers.CharField(
31         help_text="The aspect of the NS that is requested to be scaled, as declared in the NSD. ",
32         required=True)
33     numberOfSteps = serializers.CharField(
34         help_text="The number of scaling steps to be performed. Defaults to 1. ",
35         required=False,
36         allow_null=True)
37
38
39 class ScaleNsToLevelDataSerializer(serializers.Serializer):
40     nsInstantiationLevel = serializers.CharField(
41         help_text="Identifier of the target NS instantiation level "
42                   "of the current DF to which the NS instance is requested to be scaled.",
43         required=False,
44         allow_null=True)
45     nsScaleInfo = serializers.ListField(
46         help_text="For each NS scaling aspect of the current DF",
47         child=NsScaleInfoSerializer(
48             help_text="This type represents the target NS Scale level for "
49                       "each NS scaling aspect of the current deployment flavour.",
50             required=True),
51         required=False,
52         allow_null=True)
53
54
55 class ScaleNsDataSerializer(serializers.Serializer):
56     vnfInstanceToBeAdded = serializers.ListField(
57         help_text="An existing VNF instance to be added to the NS instance as part of the scaling operation.",
58         child=VnfInstanceDataSerializer(
59             help_text="This type specifies an existing VNF instance to be used in the NS instance and if needed",
60             required=True),
61         required=False,
62         allow_null=True)
63     vnfInstanceToBeRemoved = serializers.ListField(
64         help_text="The VNF instance to be removed from the NS instance as part of the scaling operation",
65         required=False,
66         allow_null=True)
67     scaleNsByStepsData = ScaleNsByStepsDataSerializer(
68         help_text="The information used to scale an NS instance by one or more scaling steps",
69         required=False,
70         allow_null=True)
71     scaleNsToLevelData = ScaleNsToLevelDataSerializer(
72         help_text="The information used to scale an NS instance to a target size. ",
73         required=False,
74         allow_null=True)
75     additionalParamsForNs = serializers.DictField(
76         help_text="Allows the OSS/BSS to provide additional parameter(s) at the NS level necessary for the NS scaling ",
77         child=serializers.CharField(help_text="KeyValue Pairs",
78                                     allow_blank=True),
79         required=False,
80         allow_null=True)
81     additionalParamsForVnf = serializers.ListField(
82         help_text="Allows the OSS/BSS to provide additional parameter(s) per VNF instance",
83         child=ParamsForVnfSerializer(
84             help_text="This type defines the additional parameters for the VNF instance to be created associated with an NS instance.",
85             required=True),
86         required=False,
87         allow_null=True)
88     locationConstraints = serializers.ListField(
89         help_text="The location constraints for the VNF to be instantiated as part of the NS scaling.",
90         child=VnfLocationConstraintSerializer(
91             help_text="This type represents the association of location constraints to a VNF instance to"
92                       "be created according to a specific VNF profile",
93             required=True),
94         required=False,
95         allow_null=True)
96
97
98 class ScaleToLevelDataSerializer(serializers.Serializer):
99     vnfInstantiationLevelId = serializers.CharField(
100         help_text="Identifier of the target instantiation level of the current deployment flavour to which the VNF is requested to be scaled.",
101         required=False,
102         allow_null=True)
103     vnfScaleInfo = serializers.ListField(
104         help_text="For each scaling aspect of the current deployment flavour",
105         child=VnfScaleInfoSerializer(
106             help_text="This type describes the provides information about the scale level of a VNF instance with respect to one scaling aspect",
107             required=True),
108         required=False,
109         allow_null=True)
110     additionalParams = serializers.DictField(
111         help_text="Additional parameters passed by the NFVO as input to the scaling process",
112         required=False,
113         allow_null=True)
114
115
116 class ScaleByStepDataSerializer(serializers.Serializer):
117     aspectId = serializers.CharField(
118         help_text="Identifier of (reference to) the aspect of the VNF that is requested to be scaled.",
119         required=True)
120     numberOfSteps = serializers.CharField(
121         help_text="Number of scaling steps.",
122         required=False,
123         allow_null=True)
124     additionalParams = serializers.DictField(
125         help_text="Additional parameters passed by the NFVO as input to the scaling process.",
126         required=False,
127         allow_null=True)
128
129
130 class ScaleVnfDataSerializers(serializers.Serializer):
131     vnfInstanceid = serializers.CharField(
132         help_text="Identifier of the VNF instance being scaled.",
133         required=True)
134
135     scaleVnfType = serializers.ChoiceField(
136         help_text="Type of the scale VNF operation requested.",
137         choices=enum_to_list(SCALE_VNF_TYPE),
138         required=True)
139
140     scaleToLevelData = ScaleToLevelDataSerializer(
141         help_text="The information used for scaling to a given level.",
142         required=False)
143
144     scaleByStepData = ScaleByStepDataSerializer(
145         help_text="The information used for scaling by steps.",
146         required=False)
147
148
149 class ScaleNsRequestSerializer(serializers.Serializer):
150     scaleType = serializers.ChoiceField(
151         help_text="Indicates the type of scaling to be performed",
152         choices=enum_to_list(SCALE_TYPE),
153         required=True)
154     scaleNsData = ScaleNsDataSerializer(
155         help_text="The necessary information to scale the referenced NS instance.",
156         required=False,
157         allow_null=True)
158     scaleVnfData = serializers.ListField(
159         help_text="Timestamp indicating the scale time of the NS",
160         child=ScaleVnfDataSerializers(
161             help_text="This type represents defines the information to scale a VNF instance to a given level",
162             required=True),
163         required=False,
164         allow_null=True)
165     scaleTime = serializers.CharField(
166         help_text="Timestamp indicating the scale time of the NS",
167         required=False,
168         allow_null=True)