1 # Copyright (C) 2018 Verizon. All Rights Reserved.
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.
16 from rest_framework import serializers
18 from affected_vnfcs import AffectedVnfcsSerializer
19 from affected_vls import AffectedVLsSerializer
20 from affected_storages import AffectedStoragesSerializer
21 from link import LinkSerializer
22 from response import ProblemDetailsSerializer
23 from ext_virtual_link_info import ExtVirtualLinkInfoSerializer
24 from vnf_info_modifications import VnfInfoModificationsSerializer
27 LCM_OPERATION_TYPES = [
39 LCM_OPERATION_STATE_TYPES = [
50 class ResourceChangesSerializer(serializers.Serializer):
51 affectedVnfcs = AffectedVnfcsSerializer(
52 help_text="Information about VNFC instances that were affected " +
53 "during the lifecycle operation.",
57 affectedVirtualLinks = AffectedVLsSerializer(
58 help_text="Information about VL instances that were affected " +
59 "during the lifecycle operation. ",
63 affectedVirtualStorages = AffectedStoragesSerializer(
64 help_text="Information about virtualised storage instances that " +
65 "were affected during the lifecycle operation",
71 class LcmOpLinkSerializer(serializers.Serializer):
72 self = LinkSerializer(
73 help_text="URI of this resource.",
76 vnfInstance = serializers.CharField(
77 help_text="Link to the VNF instance that the operation applies to.",
79 grant = serializers.CharField(
80 help_text="Link to the grant for this operation, if one exists.",
82 cancel = serializers.CharField(
83 help_text="Link to the task resource that represents the 'cancel' " +
84 "operation for this VNF LCM operation occurrence.",
86 retry = serializers.CharField(
87 help_text="Link to the task resource that represents the 'retry' " +
88 "operation for this VNF LCM operation occurrence, if" +
89 " retrying is currently allowed",
91 rollback = serializers.CharField(
92 help_text="Link to the task resource that represents the 'cancel' " +
93 "operation for this VNF LCM operation occurrence.",
95 fail = serializers.CharField(
96 help_text="Link to the task resource that represents the 'fail' " +
97 "operation for this VNF LCM operation occurrence.",
101 class VNFLCMOpOccSerializer(serializers.Serializer):
102 id = serializers.CharField(
103 help_text="Identifier of this VNF lifecycle management operation" +
109 operationState = serializers.ChoiceField(
110 help_text="The state of the VNF LCM operation occurrence. ",
112 choices=LCM_OPERATION_STATE_TYPES
114 stateEnteredTime = serializers.CharField(
115 help_text="Date-time when the current state was entered.",
118 startTime = serializers.CharField(
119 help_text="Date-time of the start of the operation.",
122 vnfInstanceId = serializers.UUIDField(
123 help_text="Identifier of the VNF instance to which the operation" +
126 grantId = serializers.UUIDField(
127 help_text="Identifier of the grant related to this VNF LCM operation " +
128 "occurrence, if such grant exists.",
131 operation = serializers.ChoiceField(
132 help_text="The lifecycle management operation",
134 choices=LCM_OPERATION_TYPES
136 isAutomaticInvocation = serializers.BooleanField(
137 help_text="Set to true if this VNF LCM operation occurrence has " +
138 "been triggered by an automated procedure inside the VNFM. " +
139 "Set to False otherwise.",
142 operationParams = serializers.DictField(
143 help_text="Input parameters of the LCM operation. This attribute " +
144 "shall be formatted according to the request data type of the " +
145 "related LCM operation. The following mapping between operationType and the " +
146 "data type of this attribute shall apply: " +
147 "1. INSTANTIATE: InstantiateVnfRequest" +
148 "2. SCALE: ScaleVnfRequest " +
149 "3. SCALE_TO_LEVEL: ScaleVnfToLevelRequest " +
150 "4. CHANGE_FLAVOUR: ChangeVnfFlavourRequest " +
151 "5. OPERATE: OperateVnfRequest " +
152 "6. HEAL: HealVnfRequest " +
153 "7. CHANGE_EXT_CONN: ChangeExtVnfConnectivityRequest " +
154 "8. TERMINATE: TerminateVnfRequest " +
155 "9. MODIFY_INFO: VnfInfoModifications",
159 isCancelPending = serializers.BooleanField(
160 help_text="If the VNF LCM operation occurrence is in 'STARTING'" +
161 "'PROCESSING' or 'ROLLING_BACK' state and the operation is being" +
162 " cancelled, this attribute shall be set to True. Otherwise, " +
163 " it shall be set to False.",
166 cancelMode = serializers.CharField(
167 help_text="The mode of an ongoing cancellation. Shall be present " +
168 "when isCancelPending=true, and shall be None otherwise.",
172 error = ProblemDetailsSerializer(
173 help_text="If 'operationState' is 'FAILED_TEMP' or 'FAILED' or " +
174 "'PROCESSING' or 'ROLLING_BACK' and previous value of 'operationState' " +
175 "was 'FAILED_TEMP' this attribute shall be present ",
179 resourceChanges = ResourceChangesSerializer(
180 help_text="It contains information about the cumulative changes " +
181 "to virtualised resources that were performed so far by the LCM " +
182 "operation since its start, if applicable.",
185 changedInfo = VnfInfoModificationsSerializer(
186 help_text="Information about the changed VNF instance information, " +
187 "including VNF configurable properties",
190 changedExtConnectivity = ExtVirtualLinkInfoSerializer(
191 help_text="Information about changed external connectivity, if this " +
192 "notification represents the result of a lifecycle operation occurrence. " +
193 "Shall be present if the 'notificationStatus' is set to 'RESULT' and the " +
194 "'operation' is set to 'CHANGE_EXT_CONN'. Shall be absent otherwise.",
198 _links = LcmOpLinkSerializer(
199 help_text="Links to resources related to this resource.",