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 rest_framework import serializers
18 LCM_OPERATION_TYPES = [
30 LCM_OPERATION_STATE_TYPES = [
40 VNFCS_CHANGE_TYPES = [
48 STORAGES_CHANGE_TYPES = [
66 class AdditionalParams(serializers.Serializer):
67 sdncontroller = serializers.CharField(help_text="sdncontroller", required=False)
68 NatIpRange = serializers.CharField(help_text="NatIpRange", required=False)
69 m6000_mng_ip = serializers.CharField(help_text="m6000_mng_ip", required=False)
70 externalPluginManageNetworkName = serializers.CharField(help_text="externalPluginManageNetworkName", required=False)
71 location = serializers.CharField(help_text="location", required=False)
72 externalManageNetworkName = serializers.CharField(help_text="externalManageNetworkName", required=False)
73 sfc_data_network = serializers.CharField(help_text="sfc_data_network", required=False)
74 externalDataNetworkName = serializers.CharField(help_text="externalDataNetworkName", required=False)
75 inputs = serializers.DictField(
77 child=serializers.CharField(help_text="but i needed to test these 2 fields somehow", allow_blank=True),
83 class VnfInstReqParamsSerializer(serializers.Serializer):
84 vnfDescriptorId = serializers.CharField(
85 help_text="Identifier that identifies the VNFD which defines the VNF instance to be created.",
90 vnfInstanceName = serializers.CharField(
91 help_text="Human-readable name of the VNF instance to be created.",
96 vnfInstanceDescription = serializers.CharField(
97 help_text="Human-readable description of the VNF instance to be created.",
102 additionalParam = AdditionalParams(
103 help_text="Additional input parameters for the instantiation process,"
104 " specific to the VNF being instantiated.",
109 class ResponseSerializer(serializers.Serializer):
110 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
111 jobId = serializers.CharField(help_text="Job ID.", required=True)
114 class VnfTermReqSerializer(serializers.Serializer):
115 vnfInstanceId = serializers.CharField(
116 help_text="VNF instance identifier.",
123 class VnfInfo(serializers.Serializer):
124 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
125 vnfStatus = serializers.CharField(help_text="The instantiation state of the VNF.", required=True)
126 version = serializers.CharField(help_text="Version of the VNF.", required=True)
129 class VnfQueryRespSerializer(serializers.Serializer):
131 help_text="The information items about the selected VNF instance(s) that are returned.",
136 class ResponseDescriptor(serializers.Serializer):
137 status = serializers.CharField(help_text="status.", required=True)
138 responsehistorylist = serializers.CharField(help_text="History response messages.", required=True)
139 responseid = serializers.IntegerField(help_text="Response identifier.", required=True)
140 errorcode = serializers.CharField(help_text="Errorcode.", required=True)
141 progress = serializers.IntegerField(help_text="Progress.", required=True)
142 statusdescription = serializers.CharField(help_text="Status description.", required=True)
145 class OperationStatusInfo(serializers.Serializer):
146 responsedescriptor = ResponseDescriptor(help_text="Response descriptor.", required=True)
147 jobid = serializers.CharField(help_text="Job ID.", required=True)
150 class VnfOperRespSerializer(serializers.Serializer):
151 operationStatusInfo = OperationStatusInfo(
152 help_text="Operation Status.",
157 class VnfGrantReqSerializer(serializers.Serializer):
158 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
159 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
160 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
161 exvimidlist = serializers.CharField(help_text="Extend VIM identifier list.", required=True)
162 tenant = serializers.CharField(help_text="Tenant name.", required=True)
163 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
164 operationright = serializers.CharField(help_text="Operation right.", required=True)
165 vmlist = serializers.CharField(help_text="VM list.", required=True)
168 class VnfGrantRespSerializer(serializers.Serializer):
169 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
170 tenant = serializers.CharField(help_text="Tenant name.", required=True)
173 class VnfNotifyReqSerializer(serializers.Serializer):
174 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
175 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
176 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
177 timestamp = serializers.CharField(help_text="Timestamp.", required=True)
178 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
179 eventtype = serializers.CharField(help_text="Event type.", required=True)
180 vmlist = serializers.CharField(help_text="VM list.", required=True)
183 class LinkSerializer(serializers.Serializer):
184 href = serializers.CharField(
185 help_text="URI of the referenced resource.",
191 class VimConnectionInfoSerializer(serializers.Serializer):
192 id = serializers.CharField(
193 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
198 vimId = serializers.CharField(
199 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
204 vimType = serializers.CharField(
205 help_text="Discriminator for the different types of the VIM information.",
210 interfaceInfo = serializers.DictField(
211 help_text="Information about the interface or interfaces to the VIM",
212 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
215 accessInfo = serializers.DictField(
216 help_text="Authentication credentials for accessing the VIM, and other access-related information",
217 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
220 extra = serializers.DictField(
221 help_text="VIM type specific additional information. \
222 The applicable structure, and whether or not this attribute is available, is dependent on the content of vimType.",
223 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
228 class ResourceHandleSerializer(serializers.Serializer):
229 vimConnectionId = serializers.CharField(
230 help_text="Identifier of the VIM connection to manage the resource.",
235 resourceProviderId = serializers.CharField(
236 help_text="Identifier of the entity responsible for the management of the resource.",
241 resourceId = serializers.CharField(
242 help_text="Identifier of the resource in the scope of the VIM or the resource provider.",
247 vimLevelResourceType = serializers.CharField(
248 help_text="String, type of the resource in the scope of the VIM or the resource provider.",
255 class ProblemDetailsSerializer(serializers.Serializer):
256 type = serializers.CharField(help_text="Type", required=False, allow_null=True)
257 title = serializers.CharField(help_text="Title", required=False, allow_null=True)
258 status = serializers.IntegerField(help_text="Status", required=True)
259 detail = serializers.CharField(help_text="Detail", required=True, allow_null=True)
260 instance = serializers.CharField(help_text="Instance", required=False, allow_null=True)
261 additional_details = serializers.ListField(
262 help_text="Any number of additional attributes, as defined in a " +
263 "specification or by an implementation.",
268 class ExtlinkPortInfoSerializer(serializers.Serializer):
269 id = serializers.CharField(
270 help_text="Identifier of this link port as provided by the entity that has created the link port.",
275 resourceHandle = ResourceHandleSerializer(
276 help_text="Reference to the virtualised resource realizing this link port.",
279 id = serializers.CharField(
280 help_text="Identifier of the external CP of the VNF connected to this link port. \
281 There shall be at most one link port associated with any external connection point instance.",
288 class ExtVirtualLinkInfoSerializer(serializers.Serializer):
289 id = serializers.CharField(
290 help_text="Identifier of the external VL and the related external VL information instance. \
291 The identifier is assigned by the NFV-MANO entity that manages this VL instance.",
296 resourceHandle = ResourceHandleSerializer(
297 help_text="Reference to the resource realizing this VL.",
300 extlinkPorts = ExtlinkPortInfoSerializer(
301 help_text="Link ports of this VL.",
307 class VnfInfoModificationsSerializer(serializers.Serializer):
308 vnfInstanceName = serializers.CharField(
309 help_text="If present, this attribute signals modifications of the " +
310 "'vnfInstanceName' attribute in 'VnfInstance'",
315 vnfInstanceDescription = serializers.CharField(
316 help_text="If present, this attribute signals modifications of the " +
317 "'vnfInstanceDescription' attribute in 'VnfInstance'",
321 vnfdId = serializers.CharField(
322 help_text="If present, this attribute signals modifications of the " +
323 "'vnfdId' attribute in 'VnfInstance'",
328 vnfProvider = serializers.CharField(
329 help_text="If present, this attribute signals modifications of the " +
330 "'vnfProvider' attribute in 'VnfInstance'",
334 vnfProductName = serializers.CharField(
335 help_text="If present, this attribute signals modifications of the " +
336 "'vnfProductName' attribute in 'vnfInstance'",
341 vnfSoftwareVersion = serializers.CharField(
342 help_text="If present, this attribute signals modifications of the " +
343 "'vnfSoftwareVersion' attribute in 'VnfInstance'.",
348 vnfdVersion = serializers.CharField(
349 help_text="If present, this attribute signals modifications of the " +
350 "'vnfdVersion' attribute in 'VnfInstance'. ",
355 vnfPkgId = serializers.CharField(
356 help_text="If present, this attribute signals modifications of the " +
357 "'vnfPkgId' attribute in 'VnfInstance'.",
362 vnfConfigurableProperties = serializers.DictField(
363 help_text="If present, this attribute signals modifications of the " +
364 "'vnfConfigurableProperties' attribute in 'VnfInstance'. ",
365 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
368 vimConnectionInfo = VimConnectionInfoSerializer(
369 help_text="If present, this attribute signals modifications of certain" +
370 "entries in the 'vimConnectionInfo'",
374 metadata = serializers.DictField(
375 help_text="If present, this attribute signals modifications of certain" +
376 "'metadata' attribute in 'vnfInstance'.",
377 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
380 extensions = serializers.DictField(
381 help_text="If present, this attribute signals modifications of certain" +
382 "'extensions' attribute in 'vnfInstance'.",
383 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
388 class LcmOpLinkSerializer(serializers.Serializer):
389 self = LinkSerializer(
390 help_text="URI of this resource.",
393 vnfInstance = serializers.CharField(
394 help_text="Link to the VNF instance that the operation applies to.",
396 grant = serializers.CharField(
397 help_text="Link to the grant for this operation, if one exists.",
399 cancel = serializers.CharField(
400 help_text="Link to the task resource that represents the 'cancel' " +
401 "operation for this VNF LCM operation occurrence.",
403 retry = serializers.CharField(
404 help_text="Link to the task resource that represents the 'retry' " +
405 "operation for this VNF LCM operation occurrence, if" +
406 " retrying is currently allowed",
408 rollback = serializers.CharField(
409 help_text="Link to the task resource that represents the 'cancel' " +
410 "operation for this VNF LCM operation occurrence.",
412 fail = serializers.CharField(
413 help_text="Link to the task resource that represents the 'fail' " +
414 "operation for this VNF LCM operation occurrence.",
418 class AffectedVnfcsSerializer(serializers.Serializer):
419 id = serializers.UUIDField(
420 help_text="Identifier of the Vnfc instance, identifying the " +
421 "applicable 'vnfcResourceInfo' entry in the 'VnfInstance' data type",
424 vduId = serializers.UUIDField(
425 help_text="Identifier of the related VDU in the VNFD.",
428 changeType = serializers.ChoiceField(
429 help_text="Signals the type of change",
431 choices=VNFCS_CHANGE_TYPES
433 affectedVnfcCpIds = serializers.ListField(
434 help_text="Identifiers of CP(s) of the VNFC instance that " +
435 "were affected by the change",
437 child=serializers.UUIDField(required=True)
439 addedStorageResourceIds = serializers.ListField(
440 help_text="References to VirtualStorage resources that " +
443 child=serializers.UUIDField()
445 removedStorageResourceIds = serializers.ListField(
446 help_text="References to VirtualStorage resources that " +
447 "have been removed.",
449 child=serializers.UUIDField()
451 metadata = serializers.DictField(
452 help_text="Metadata about this resource. ",
455 computeResource = ResourceHandleSerializer(
456 help_text="Reference to the VirtualCompute resource.",
461 class AffectedStoragesSerializer(serializers.Serializer):
462 id = serializers.UUIDField(
463 help_text="Identifier of the Storage instance, identifying the " +
464 "applicable 'virtualStorageResourceInfo' entry in the 'VnfInstance' data type",
467 virtualStorageDescId = serializers.UUIDField(
468 help_text="Identifier of the related VirtualStorage descriptor " +
472 changeType = serializers.ChoiceField(
473 help_text="Signals the type of change",
475 choices=STORAGES_CHANGE_TYPES
477 metadata = serializers.DictField(
478 help_text="Metadata about this resource. ",
481 storageResource = ResourceHandleSerializer(
482 help_text="Reference to the VirtualStorage resource.",
487 class AffectedVLsSerializer(serializers.Serializer):
488 id = serializers.UUIDField(
489 help_text="Identifier of the virtual link instance, identifying " +
490 "the applicable 'vnfVirtualLinkResourceInfo' ",
493 virtualLinkDescId = serializers.UUIDField(
494 help_text="Identifier of the related VLD in the VNFD.",
497 changeType = serializers.ChoiceField(
498 help_text="Signals the type of change",
500 choices=VLS_CHANGE_TYPES
502 metadata = serializers.DictField(
503 help_text="Metadata about this resource. ",
506 networkResource = ResourceHandleSerializer(
507 help_text="Reference to the VirtualNetwork resource.",
512 class ResourceChangesSerializer(serializers.Serializer):
513 affectedVnfcs = AffectedVnfcsSerializer(
514 help_text="Information about VNFC instances that were affected " +
515 "during the lifecycle operation.",
519 affectedVirtualLinks = AffectedVLsSerializer(
520 help_text="Information about VL instances that were affected " +
521 "during the lifecycle operation. ",
525 affectedVirtualStorages = AffectedStoragesSerializer(
526 help_text="Information about virtualised storage instances that " +
527 "were affected during the lifecycle operation",
533 class VNFLCMOpOccSerializer(serializers.Serializer):
534 id = serializers.CharField(
535 help_text="Identifier of this VNF lifecycle management operation" +
541 operationState = serializers.ChoiceField(
542 help_text="The state of the VNF LCM operation occurrence. ",
544 choices=LCM_OPERATION_STATE_TYPES
546 stateEnteredTime = serializers.CharField(
547 help_text="Date-time when the current state was entered.",
550 startTime = serializers.CharField(
551 help_text="Date-time of the start of the operation.",
554 vnfInstanceId = serializers.UUIDField(
555 help_text="Identifier of the VNF instance to which the operation" +
558 grantId = serializers.UUIDField(
559 help_text="Identifier of the grant related to this VNF LCM operation " +
560 "occurrence, if such grant exists.",
563 operation = serializers.ChoiceField(
564 help_text="The lifecycle management operation",
566 choices=LCM_OPERATION_TYPES
568 isAutomaticInvocation = serializers.BooleanField(
569 help_text="Set to true if this VNF LCM operation occurrence has " +
570 "been triggered by an automated procedure inside the VNFM. " +
571 "Set to False otherwise.",
574 operationParams = serializers.DictField(
575 help_text="Input parameters of the LCM operation. This attribute " +
576 "shall be formatted according to the request data type of the " +
577 "related LCM operation. The following mapping between operationType and the " +
578 "data type of this attribute shall apply: " +
579 "1. INSTANTIATE: InstantiateVnfRequest" +
580 "2. SCALE: ScaleVnfRequest " +
581 "3. SCALE_TO_LEVEL: ScaleVnfToLevelRequest " +
582 "4. CHANGE_FLAVOUR: ChangeVnfFlavourRequest " +
583 "5. OPERATE: OperateVnfRequest " +
584 "6. HEAL: HealVnfRequest " +
585 "7. CHANGE_EXT_CONN: ChangeExtVnfConnectivityRequest " +
586 "8. TERMINATE: TerminateVnfRequest " +
587 "9. MODIFY_INFO: VnfInfoModifications",
591 isCancelPending = serializers.BooleanField(
592 help_text="If the VNF LCM operation occurrence is in 'STARTING'" +
593 "'PROCESSING' or 'ROLLING_BACK' state and the operation is being" +
594 " cancelled, this attribute shall be set to True. Otherwise, " +
595 " it shall be set to False.",
598 cancelMode = serializers.CharField(
599 help_text="The mode of an ongoing cancellation. Shall be present " +
600 "when isCancelPending=true, and shall be None otherwise.",
604 error = ProblemDetailsSerializer(
605 help_text="If 'operationState' is 'FAILED_TEMP' or 'FAILED' or " +
606 "'PROCESSING' or 'ROLLING_BACK' and previous value of 'operationState' " +
607 "was 'FAILED_TEMP' this attribute shall be present ",
611 resourceChanges = ResourceChangesSerializer(
612 help_text="It contains information about the cumulative changes " +
613 "to virtualised resources that were performed so far by the LCM " +
614 "operation since its start, if applicable.",
617 changedInfo = VnfInfoModificationsSerializer(
618 help_text="Information about the changed VNF instance information, " +
619 "including VNF configurable properties",
622 changedExtConnectivity = ExtVirtualLinkInfoSerializer(
623 help_text="Information about changed external connectivity, if this " +
624 "notification represents the result of a lifecycle operation occurrence. " +
625 "Shall be present if the 'notificationStatus' is set to 'RESULT' and the " +
626 "'operation' is set to 'CHANGE_EXT_CONN'. Shall be absent otherwise.",
630 _links = LcmOpLinkSerializer(
631 help_text="Links to resources related to this resource.",