1 # Copyright 2018 ZTE Corporation.
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.
15 from driver.interfaces.serializers.link import LinkSerializer
16 from driver.interfaces.serializers.resource_handle import ResourceHandleSerializer
18 from rest_framework import serializers
20 LCM_OPERATION_TYPES = [
33 LCM_OPERATION_STATE_TYPES = [
44 VNFCS_CHANGE_TYPES = [
52 STORAGES_CHANGE_TYPES = [
70 class AdditionalParams(serializers.Serializer):
71 sdncontroller = serializers.CharField(help_text="sdncontroller", required=False)
72 NatIpRange = serializers.CharField(help_text="NatIpRange", required=False)
73 m6000_mng_ip = serializers.CharField(help_text="m6000_mng_ip", required=False)
74 externalPluginManageNetworkName = serializers.CharField(help_text="externalPluginManageNetworkName", required=False)
75 location = serializers.CharField(help_text="location", required=False)
76 externalManageNetworkName = serializers.CharField(help_text="externalManageNetworkName", required=False)
77 sfc_data_network = serializers.CharField(help_text="sfc_data_network", required=False)
78 externalDataNetworkName = serializers.CharField(help_text="externalDataNetworkName", required=False)
79 inputs = serializers.DictField(
81 child=serializers.CharField(help_text="but i needed to test these 2 fields somehow", allow_blank=True),
87 class VnfInstReqParamsSerializer(serializers.Serializer):
88 vnfDescriptorId = serializers.CharField(
89 help_text="Identifier that identifies the VNFD which defines the VNF instance to be created.",
94 vnfInstanceName = serializers.CharField(
95 help_text="Human-readable name of the VNF instance to be created.",
100 vnfInstanceDescription = serializers.CharField(
101 help_text="Human-readable description of the VNF instance to be created.",
106 additionalParam = AdditionalParams(
107 help_text="Additional input parameters for the instantiation process,"
108 " specific to the VNF being instantiated.",
113 class ResponseSerializer(serializers.Serializer):
114 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
115 jobId = serializers.CharField(help_text="Job ID.", required=True)
118 class VnfTermReqSerializer(serializers.Serializer):
119 vnfInstanceId = serializers.CharField(
120 help_text="VNF instance identifier.",
127 class VnfInfo(serializers.Serializer):
128 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
129 vnfStatus = serializers.CharField(help_text="The instantiation state of the VNF.", required=True)
130 version = serializers.CharField(help_text="Version of the VNF.", required=True)
133 class VnfQueryRespSerializer(serializers.Serializer):
135 help_text="The information items about the selected VNF instance(s) that are returned.",
140 class ResponseDescriptor(serializers.Serializer):
141 status = serializers.CharField(help_text="status.", required=True)
142 responsehistorylist = serializers.CharField(help_text="History response messages.", required=True)
143 responseid = serializers.IntegerField(help_text="Response identifier.", required=True)
144 errorcode = serializers.CharField(help_text="Errorcode.", required=True)
145 progress = serializers.IntegerField(help_text="Progress.", required=True)
146 statusdescription = serializers.CharField(help_text="Status description.", required=True)
149 class OperationStatusInfo(serializers.Serializer):
150 responsedescriptor = ResponseDescriptor(help_text="Response descriptor.", required=True)
151 jobid = serializers.CharField(help_text="Job ID.", required=True)
154 class VnfOperRespSerializer(serializers.Serializer):
155 operationStatusInfo = OperationStatusInfo(
156 help_text="Operation Status.",
161 class VnfGrantReqSerializer(serializers.Serializer):
162 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
163 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
164 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
165 exvimidlist = serializers.CharField(help_text="Extend VIM identifier list.", required=True)
166 tenant = serializers.CharField(help_text="Tenant name.", required=True)
167 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
168 operationright = serializers.CharField(help_text="Operation right.", required=True)
169 vmlist = serializers.CharField(help_text="VM list.", required=True)
172 class VnfGrantRespSerializer(serializers.Serializer):
173 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
174 tenant = serializers.CharField(help_text="Tenant name.", required=True)
177 class VnfNotifyReqSerializer(serializers.Serializer):
178 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
179 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
180 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
181 timestamp = serializers.CharField(help_text="Timestamp.", required=True)
182 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
183 eventtype = serializers.CharField(help_text="Event type.", required=True)
184 vmlist = serializers.CharField(help_text="VM list.", required=True)
187 class VimConnectionInfoSerializer(serializers.Serializer):
188 id = serializers.CharField(
189 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
194 vimId = serializers.CharField(
195 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
200 vimType = serializers.CharField(
201 help_text="Discriminator for the different types of the VIM information.",
206 interfaceInfo = serializers.DictField(
207 help_text="Information about the interface or interfaces to the VIM",
208 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
211 accessInfo = serializers.DictField(
212 help_text="Authentication credentials for accessing the VIM, and other access-related information",
213 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
216 extra = serializers.DictField(
217 help_text="VIM type specific additional information. \
218 The applicable structure, and whether or not this attribute is available, is dependent on the content of vimType.",
219 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
224 class ProblemDetailsSerializer(serializers.Serializer):
225 type = serializers.CharField(help_text="Type", required=False, allow_null=True)
226 title = serializers.CharField(help_text="Title", required=False, allow_null=True)
227 status = serializers.IntegerField(help_text="Status", required=True)
228 detail = serializers.CharField(help_text="Detail", required=True, allow_null=True)
229 instance = serializers.CharField(help_text="Instance", required=False, allow_null=True)
230 additional_details = serializers.ListField(
231 help_text="Any number of additional attributes, as defined in a " +
232 "specification or by an implementation.",
237 class ExtlinkPortInfoSerializer(serializers.Serializer):
238 id = serializers.CharField(
239 help_text="Identifier of this link port as provided by the entity that has created the link port.",
244 resourceHandle = ResourceHandleSerializer(
245 help_text="Reference to the virtualised resource realizing this link port.",
248 id = serializers.CharField(
249 help_text="Identifier of the external CP of the VNF connected to this link port. \
250 There shall be at most one link port associated with any external connection point instance.",
257 class ExtVirtualLinkInfoSerializer(serializers.Serializer):
258 id = serializers.CharField(
259 help_text="Identifier of the external VL and the related external VL information instance. \
260 The identifier is assigned by the NFV-MANO entity that manages this VL instance.",
265 resourceHandle = ResourceHandleSerializer(
266 help_text="Reference to the resource realizing this VL.",
269 extlinkPorts = ExtlinkPortInfoSerializer(
270 help_text="Link ports of this VL.",
276 class VnfInfoModificationsSerializer(serializers.Serializer):
277 vnfInstanceName = serializers.CharField(
278 help_text="If present, this attribute signals modifications of the " +
279 "'vnfInstanceName' attribute in 'VnfInstance'",
284 vnfInstanceDescription = serializers.CharField(
285 help_text="If present, this attribute signals modifications of the " +
286 "'vnfInstanceDescription' attribute in 'VnfInstance'",
290 vnfdId = serializers.CharField(
291 help_text="If present, this attribute signals modifications of the " +
292 "'vnfdId' attribute in 'VnfInstance'",
297 vnfProvider = serializers.CharField(
298 help_text="If present, this attribute signals modifications of the " +
299 "'vnfProvider' attribute in 'VnfInstance'",
303 vnfProductName = serializers.CharField(
304 help_text="If present, this attribute signals modifications of the " +
305 "'vnfProductName' attribute in 'vnfInstance'",
310 vnfSoftwareVersion = serializers.CharField(
311 help_text="If present, this attribute signals modifications of the " +
312 "'vnfSoftwareVersion' attribute in 'VnfInstance'.",
317 vnfdVersion = serializers.CharField(
318 help_text="If present, this attribute signals modifications of the " +
319 "'vnfdVersion' attribute in 'VnfInstance'. ",
324 vnfPkgId = serializers.CharField(
325 help_text="If present, this attribute signals modifications of the " +
326 "'vnfPkgId' attribute in 'VnfInstance'.",
331 vnfConfigurableProperties = serializers.DictField(
332 help_text="If present, this attribute signals modifications of the " +
333 "'vnfConfigurableProperties' attribute in 'VnfInstance'. ",
334 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
337 vimConnectionInfo = VimConnectionInfoSerializer(
338 help_text="If present, this attribute signals modifications of certain" +
339 "entries in the 'vimConnectionInfo'",
343 metadata = serializers.DictField(
344 help_text="If present, this attribute signals modifications of certain" +
345 "'metadata' attribute in 'vnfInstance'.",
346 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
349 extensions = serializers.DictField(
350 help_text="If present, this attribute signals modifications of certain" +
351 "'extensions' attribute in 'vnfInstance'.",
352 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
357 class LcmOpLinkSerializer(serializers.Serializer):
358 self = LinkSerializer(
359 help_text="URI of this resource.",
362 vnfInstance = serializers.CharField(
363 help_text="Link to the VNF instance that the operation applies to.",
365 grant = serializers.CharField(
366 help_text="Link to the grant for this operation, if one exists.",
368 cancel = serializers.CharField(
369 help_text="Link to the task resource that represents the 'cancel' " +
370 "operation for this VNF LCM operation occurrence.",
372 retry = serializers.CharField(
373 help_text="Link to the task resource that represents the 'retry' " +
374 "operation for this VNF LCM operation occurrence, if" +
375 " retrying is currently allowed",
377 rollback = serializers.CharField(
378 help_text="Link to the task resource that represents the 'cancel' " +
379 "operation for this VNF LCM operation occurrence.",
381 fail = serializers.CharField(
382 help_text="Link to the task resource that represents the 'fail' " +
383 "operation for this VNF LCM operation occurrence.",
387 class AffectedVnfcsSerializer(serializers.Serializer):
388 id = serializers.UUIDField(
389 help_text="Identifier of the Vnfc instance, identifying the " +
390 "applicable 'vnfcResourceInfo' entry in the 'VnfInstance' data type",
393 vduId = serializers.UUIDField(
394 help_text="Identifier of the related VDU in the VNFD.",
397 changeType = serializers.ChoiceField(
398 help_text="Signals the type of change",
400 choices=VNFCS_CHANGE_TYPES
402 affectedVnfcCpIds = serializers.ListField(
403 help_text="Identifiers of CP(s) of the VNFC instance that " +
404 "were affected by the change",
406 child=serializers.UUIDField(required=True)
408 addedStorageResourceIds = serializers.ListField(
409 help_text="References to VirtualStorage resources that " +
412 child=serializers.UUIDField()
414 removedStorageResourceIds = serializers.ListField(
415 help_text="References to VirtualStorage resources that " +
416 "have been removed.",
418 child=serializers.UUIDField()
420 metadata = serializers.DictField(
421 help_text="Metadata about this resource. ",
424 computeResource = ResourceHandleSerializer(
425 help_text="Reference to the VirtualCompute resource.",
430 class AffectedStoragesSerializer(serializers.Serializer):
431 id = serializers.UUIDField(
432 help_text="Identifier of the Storage instance, identifying the " +
433 "applicable 'virtualStorageResourceInfo' entry in the 'VnfInstance' data type",
436 virtualStorageDescId = serializers.UUIDField(
437 help_text="Identifier of the related VirtualStorage descriptor " +
441 changeType = serializers.ChoiceField(
442 help_text="Signals the type of change",
444 choices=STORAGES_CHANGE_TYPES
446 metadata = serializers.DictField(
447 help_text="Metadata about this resource. ",
450 storageResource = ResourceHandleSerializer(
451 help_text="Reference to the VirtualStorage resource.",
456 class AffectedVLsSerializer(serializers.Serializer):
457 id = serializers.UUIDField(
458 help_text="Identifier of the virtual link instance, identifying " +
459 "the applicable 'vnfVirtualLinkResourceInfo' ",
462 virtualLinkDescId = serializers.UUIDField(
463 help_text="Identifier of the related VLD in the VNFD.",
466 changeType = serializers.ChoiceField(
467 help_text="Signals the type of change",
469 choices=VLS_CHANGE_TYPES
471 metadata = serializers.DictField(
472 help_text="Metadata about this resource. ",
475 networkResource = ResourceHandleSerializer(
476 help_text="Reference to the VirtualNetwork resource.",
481 class ResourceChangesSerializer(serializers.Serializer):
482 affectedVnfcs = AffectedVnfcsSerializer(
483 help_text="Information about VNFC instances that were affected " +
484 "during the lifecycle operation.",
488 affectedVirtualLinks = AffectedVLsSerializer(
489 help_text="Information about VL instances that were affected " +
490 "during the lifecycle operation. ",
494 affectedVirtualStorages = AffectedStoragesSerializer(
495 help_text="Information about virtualised storage instances that " +
496 "were affected during the lifecycle operation",
502 class VNFLCMOpOccSerializer(serializers.Serializer):
503 id = serializers.CharField(
504 help_text="Identifier of this VNF lifecycle management operation" +
510 operationState = serializers.ChoiceField(
511 help_text="The state of the VNF LCM operation occurrence. ",
513 choices=LCM_OPERATION_STATE_TYPES
515 stateEnteredTime = serializers.CharField(
516 help_text="Date-time when the current state was entered.",
519 startTime = serializers.CharField(
520 help_text="Date-time of the start of the operation.",
523 vnfInstanceId = serializers.UUIDField(
524 help_text="Identifier of the VNF instance to which the operation" +
527 grantId = serializers.UUIDField(
528 help_text="Identifier of the grant related to this VNF LCM operation " +
529 "occurrence, if such grant exists.",
532 operation = serializers.ChoiceField(
533 help_text="The lifecycle management operation",
535 choices=LCM_OPERATION_TYPES
537 isAutomaticInvocation = serializers.BooleanField(
538 help_text="Set to true if this VNF LCM operation occurrence has " +
539 "been triggered by an automated procedure inside the VNFM. " +
540 "Set to False otherwise.",
543 operationParams = serializers.DictField(
544 help_text="Input parameters of the LCM operation. This attribute " +
545 "shall be formatted according to the request data type of the " +
546 "related LCM operation. The following mapping between operationType and the " +
547 "data type of this attribute shall apply: " +
548 "1. INSTANTIATE: InstantiateVnfRequest" +
549 "2. SCALE: ScaleVnfRequest " +
550 "3. SCALE_TO_LEVEL: ScaleVnfToLevelRequest " +
551 "4. CHANGE_FLAVOUR: ChangeVnfFlavourRequest " +
552 "5. OPERATE: OperateVnfRequest " +
553 "6. HEAL: HealVnfRequest " +
554 "7. CHANGE_EXT_CONN: ChangeExtVnfConnectivityRequest " +
555 "8. TERMINATE: TerminateVnfRequest " +
556 "9. MODIFY_INFO: VnfInfoModifications",
560 isCancelPending = serializers.BooleanField(
561 help_text="If the VNF LCM operation occurrence is in 'STARTING'" +
562 "'PROCESSING' or 'ROLLING_BACK' state and the operation is being" +
563 " cancelled, this attribute shall be set to True. Otherwise, " +
564 " it shall be set to False.",
567 cancelMode = serializers.CharField(
568 help_text="The mode of an ongoing cancellation. Shall be present " +
569 "when isCancelPending=true, and shall be None otherwise.",
573 error = ProblemDetailsSerializer(
574 help_text="If 'operationState' is 'FAILED_TEMP' or 'FAILED' or " +
575 "'PROCESSING' or 'ROLLING_BACK' and previous value of 'operationState' " +
576 "was 'FAILED_TEMP' this attribute shall be present ",
580 resourceChanges = ResourceChangesSerializer(
581 help_text="It contains information about the cumulative changes " +
582 "to virtualised resources that were performed so far by the LCM " +
583 "operation since its start, if applicable.",
586 changedInfo = VnfInfoModificationsSerializer(
587 help_text="Information about the changed VNF instance information, " +
588 "including VNF configurable properties",
591 changedExtConnectivity = ExtVirtualLinkInfoSerializer(
592 help_text="Information about changed external connectivity, if this " +
593 "notification represents the result of a lifecycle operation occurrence. " +
594 "Shall be present if the 'notificationStatus' is set to 'RESULT' and the " +
595 "'operation' is set to 'CHANGE_EXT_CONN'. Shall be absent otherwise.",
599 _links = LcmOpLinkSerializer(
600 help_text="Links to resources related to this resource.",