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
17 LCM_OPERATION_TYPES = [
30 LCM_OPERATION_STATE_TYPES = [
41 VNFCS_CHANGE_TYPES = [
49 STORAGES_CHANGE_TYPES = [
67 class ResourceHandleSerializer(serializers.Serializer):
68 vimConnectionId = serializers.CharField(
69 help_text="Identifier of the VIM connection to manage the resource.",
74 resourceProviderId = serializers.CharField(
75 help_text="Identifier of the entity responsible for the management of the resource.",
80 resourceId = serializers.CharField(
81 help_text="Identifier of the resource in the scope of the VIM or the resource provider.",
84 vimLevelResourceType = serializers.CharField(
85 help_text="Type of the resource in the scope of the VIM or the resource provider.",
92 class ResourceDefinitionSerializer(serializers.Serializer):
93 id = serializers.CharField(
94 help_text="Identifier of this ResourceDefinition, unique at least within the scope of the GrantRequest.",
97 type = serializers.ChoiceField(
98 help_text="Type of the resource definition referenced.",
99 choices=["COMPUTE", "VL", "STORAGE", "LINKPORT"],
102 vduId = serializers.CharField(
103 help_text="Reference to the related VDU in the VNFD applicable to this resource.",
108 resourceTemplateId = serializers.CharField(
109 help_text="Reference to a resource template(such as VnfVirtualLinkDesc) in the VNFD.",
114 resource = ResourceHandleSerializer(
115 help_text="Resource information for an existing resource.",
121 class ConstraintResourceRefSerializer(serializers.Serializer):
122 idType = serializers.ChoiceField(
123 help_text="The type of the identifier.",
124 choices=["RES_MGMT", "GRANT"],
127 resourceId = serializers.CharField(
128 help_text="An actual resource-management-level identifier(idType=RES_MGMT), or an identifier that references a ResourceDefinition(idType=GRANT).",
131 vimConnectionId = serializers.CharField(
137 resourceProviderId = serializers.CharField(
138 help_text="Identifier of the resource provider. It shall only be present when idType = RES_MGMT.",
145 class AdditionalParams(serializers.Serializer):
146 sdncontroller = serializers.CharField(help_text="sdncontroller", required=False)
147 NatIpRange = serializers.CharField(help_text="NatIpRange", required=False)
148 m6000_mng_ip = serializers.CharField(help_text="m6000_mng_ip", required=False)
149 externalPluginManageNetworkName = serializers.CharField(help_text="externalPluginManageNetworkName", required=False)
150 location = serializers.CharField(help_text="location", required=False)
151 externalManageNetworkName = serializers.CharField(help_text="externalManageNetworkName", required=False)
152 sfc_data_network = serializers.CharField(help_text="sfc_data_network", required=False)
153 externalDataNetworkName = serializers.CharField(help_text="externalDataNetworkName", required=False)
154 inputs = serializers.DictField(
156 child=serializers.CharField(help_text="but i needed to test these 2 fields somehow", allow_blank=True),
162 class VnfInstReqParamsSerializer(serializers.Serializer):
163 vnfDescriptorId = serializers.CharField(
164 help_text="Identifier that identifies the VNFD which defines the VNF instance to be created.",
169 vnfInstanceName = serializers.CharField(
170 help_text="Human-readable name of the VNF instance to be created.",
175 vnfInstanceDescription = serializers.CharField(
176 help_text="Human-readable description of the VNF instance to be created.",
181 additionalParam = AdditionalParams(
182 help_text="Additional input parameters for the instantiation process,"
183 " specific to the VNF being instantiated.",
188 class ResponseSerializer(serializers.Serializer):
189 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
190 jobId = serializers.CharField(help_text="Job ID.", required=True)
193 class VnfTermReqSerializer(serializers.Serializer):
194 vnfInstanceId = serializers.CharField(
195 help_text="VNF instance identifier.",
202 class VnfInfo(serializers.Serializer):
203 vnfInstanceId = serializers.CharField(help_text="VNF instance identifier.", required=True)
204 vnfStatus = serializers.CharField(help_text="The instantiation state of the VNF.", required=True)
205 version = serializers.CharField(help_text="Version of the VNF.", required=True)
208 class VnfQueryRespSerializer(serializers.Serializer):
210 help_text="The information items about the selected VNF instance(s) that are returned.",
215 class ResponseDescriptor(serializers.Serializer):
216 status = serializers.CharField(help_text="status.", required=True)
217 responsehistorylist = serializers.CharField(help_text="History response messages.", required=True)
218 responseid = serializers.IntegerField(help_text="Response identifier.", required=True)
219 errorcode = serializers.CharField(help_text="Errorcode.", required=True)
220 progress = serializers.IntegerField(help_text="Progress.", required=True)
221 statusdescription = serializers.CharField(help_text="Status description.", required=True)
224 class OperationStatusInfo(serializers.Serializer):
225 responsedescriptor = ResponseDescriptor(help_text="Response descriptor.", required=True)
226 jobid = serializers.CharField(help_text="Job ID.", required=True)
229 class VnfOperRespSerializer(serializers.Serializer):
230 operationStatusInfo = OperationStatusInfo(
231 help_text="Operation Status.",
236 class VnfGrantReqSerializer(serializers.Serializer):
237 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
238 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
239 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
240 exvimidlist = serializers.CharField(help_text="Extend VIM identifier list.", required=True)
241 tenant = serializers.CharField(help_text="Tenant name.", required=True)
242 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
243 operationright = serializers.CharField(help_text="Operation right.", required=True)
244 vmlist = serializers.CharField(help_text="VM list.", required=True)
247 class VnfGrantRespSerializer(serializers.Serializer):
248 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
249 tenant = serializers.CharField(help_text="Tenant name.", required=True)
252 class VnfNotifyReqSerializer(serializers.Serializer):
253 nfvoid = serializers.CharField(help_text="NFVO identifier.", required=True)
254 vnfmid = serializers.CharField(help_text="VNFM identifier.", required=True)
255 vimid = serializers.CharField(help_text="VIM identifier.", required=True)
256 timestamp = serializers.CharField(help_text="Timestamp.", required=True)
257 vnfistanceid = serializers.CharField(help_text="VNF instance identifier.", required=True)
258 eventtype = serializers.CharField(help_text="Event type.", required=True)
259 vmlist = serializers.CharField(help_text="VM list.", required=True)
262 class LinkSerializer(serializers.Serializer):
263 href = serializers.CharField(
264 help_text="URI of the referenced resource.",
270 class VimConnectionInfoSerializer(serializers.Serializer):
271 id = serializers.CharField(
272 help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
277 vimId = serializers.CharField(
278 help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
283 vimType = serializers.CharField(
284 help_text="Discriminator for the different types of the VIM information.",
289 interfaceInfo = serializers.DictField(
290 help_text="Information about the interface or interfaces to the VIM",
291 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
294 accessInfo = serializers.DictField(
295 help_text="Authentication credentials for accessing the VIM, and other access-related information",
296 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
299 extra = serializers.DictField(
300 help_text="VIM type specific additional information. \
301 The applicable structure, and whether or not this attribute is available, is dependent on the content of vimType.",
302 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
307 class ResourceHandleSerializer(serializers.Serializer):
308 vimConnectionId = serializers.CharField(
309 help_text="Identifier of the VIM connection to manage the resource.",
314 resourceProviderId = serializers.CharField(
315 help_text="Identifier of the entity responsible for the management of the resource.",
320 resourceId = serializers.CharField(
321 help_text="Identifier of the resource in the scope of the VIM or the resource provider.",
326 vimLevelResourceType = serializers.CharField(
327 help_text="String, type of the resource in the scope of the VIM or the resource provider.",
334 class ProblemDetailsSerializer(serializers.Serializer):
335 type = serializers.CharField(help_text="Type", required=False, allow_null=True)
336 title = serializers.CharField(help_text="Title", required=False, allow_null=True)
337 status = serializers.IntegerField(help_text="Status", required=True)
338 detail = serializers.CharField(help_text="Detail", required=True, allow_null=True)
339 instance = serializers.CharField(help_text="Instance", required=False, allow_null=True)
340 additional_details = serializers.ListField(
341 help_text="Any number of additional attributes, as defined in a " +
342 "specification or by an implementation.",
347 class ExtlinkPortInfoSerializer(serializers.Serializer):
348 id = serializers.CharField(
349 help_text="Identifier of this link port as provided by the entity that has created the link port.",
354 resourceHandle = ResourceHandleSerializer(
355 help_text="Reference to the virtualised resource realizing this link port.",
358 id = serializers.CharField(
359 help_text="Identifier of the external CP of the VNF connected to this link port. \
360 There shall be at most one link port associated with any external connection point instance.",
367 class ExtVirtualLinkInfoSerializer(serializers.Serializer):
368 id = serializers.CharField(
369 help_text="Identifier of the external VL and the related external VL information instance. \
370 The identifier is assigned by the NFV-MANO entity that manages this VL instance.",
375 resourceHandle = ResourceHandleSerializer(
376 help_text="Reference to the resource realizing this VL.",
379 extlinkPorts = ExtlinkPortInfoSerializer(
380 help_text="Link ports of this VL.",
386 class VnfInfoModificationsSerializer(serializers.Serializer):
387 vnfInstanceName = serializers.CharField(
388 help_text="If present, this attribute signals modifications of the " +
389 "'vnfInstanceName' attribute in 'VnfInstance'",
394 vnfInstanceDescription = serializers.CharField(
395 help_text="If present, this attribute signals modifications of the " +
396 "'vnfInstanceDescription' attribute in 'VnfInstance'",
400 vnfdId = serializers.CharField(
401 help_text="If present, this attribute signals modifications of the " +
402 "'vnfdId' attribute in 'VnfInstance'",
407 vnfProvider = serializers.CharField(
408 help_text="If present, this attribute signals modifications of the " +
409 "'vnfProvider' attribute in 'VnfInstance'",
413 vnfProductName = serializers.CharField(
414 help_text="If present, this attribute signals modifications of the " +
415 "'vnfProductName' attribute in 'vnfInstance'",
420 vnfSoftwareVersion = serializers.CharField(
421 help_text="If present, this attribute signals modifications of the " +
422 "'vnfSoftwareVersion' attribute in 'VnfInstance'.",
427 vnfdVersion = serializers.CharField(
428 help_text="If present, this attribute signals modifications of the " +
429 "'vnfdVersion' attribute in 'VnfInstance'. ",
434 vnfPkgId = serializers.CharField(
435 help_text="If present, this attribute signals modifications of the " +
436 "'vnfPkgId' attribute in 'VnfInstance'.",
441 vnfConfigurableProperties = serializers.DictField(
442 help_text="If present, this attribute signals modifications of the " +
443 "'vnfConfigurableProperties' attribute in 'VnfInstance'. ",
444 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
447 vimConnectionInfo = VimConnectionInfoSerializer(
448 help_text="If present, this attribute signals modifications of certain" +
449 "entries in the 'vimConnectionInfo'",
453 metadata = serializers.DictField(
454 help_text="If present, this attribute signals modifications of certain" +
455 "'metadata' attribute in 'vnfInstance'.",
456 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
459 extensions = serializers.DictField(
460 help_text="If present, this attribute signals modifications of certain" +
461 "'extensions' attribute in 'vnfInstance'.",
462 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
467 class LcmOpLinkSerializer(serializers.Serializer):
468 self = LinkSerializer(
469 help_text="URI of this resource.",
472 vnfInstance = serializers.CharField(
473 help_text="Link to the VNF instance that the operation applies to.",
475 grant = serializers.CharField(
476 help_text="Link to the grant for this operation, if one exists.",
478 cancel = serializers.CharField(
479 help_text="Link to the task resource that represents the 'cancel' " +
480 "operation for this VNF LCM operation occurrence.",
482 retry = serializers.CharField(
483 help_text="Link to the task resource that represents the 'retry' " +
484 "operation for this VNF LCM operation occurrence, if" +
485 " retrying is currently allowed",
487 rollback = serializers.CharField(
488 help_text="Link to the task resource that represents the 'cancel' " +
489 "operation for this VNF LCM operation occurrence.",
491 fail = serializers.CharField(
492 help_text="Link to the task resource that represents the 'fail' " +
493 "operation for this VNF LCM operation occurrence.",
497 class AffectedVnfcsSerializer(serializers.Serializer):
498 id = serializers.UUIDField(
499 help_text="Identifier of the Vnfc instance, identifying the " +
500 "applicable 'vnfcResourceInfo' entry in the 'VnfInstance' data type",
503 vduId = serializers.UUIDField(
504 help_text="Identifier of the related VDU in the VNFD.",
507 changeType = serializers.ChoiceField(
508 help_text="Signals the type of change",
510 choices=VNFCS_CHANGE_TYPES
512 affectedVnfcCpIds = serializers.ListField(
513 help_text="Identifiers of CP(s) of the VNFC instance that " +
514 "were affected by the change",
516 child=serializers.UUIDField(required=True)
518 addedStorageResourceIds = serializers.ListField(
519 help_text="References to VirtualStorage resources that " +
522 child=serializers.UUIDField()
524 removedStorageResourceIds = serializers.ListField(
525 help_text="References to VirtualStorage resources that " +
526 "have been removed.",
528 child=serializers.UUIDField()
530 metadata = serializers.DictField(
531 help_text="Metadata about this resource. ",
534 computeResource = ResourceHandleSerializer(
535 help_text="Reference to the VirtualCompute resource.",
540 class AffectedStoragesSerializer(serializers.Serializer):
541 id = serializers.UUIDField(
542 help_text="Identifier of the Storage instance, identifying the " +
543 "applicable 'virtualStorageResourceInfo' entry in the 'VnfInstance' data type",
546 virtualStorageDescId = serializers.UUIDField(
547 help_text="Identifier of the related VirtualStorage descriptor " +
551 changeType = serializers.ChoiceField(
552 help_text="Signals the type of change",
554 choices=STORAGES_CHANGE_TYPES
556 metadata = serializers.DictField(
557 help_text="Metadata about this resource. ",
560 storageResource = ResourceHandleSerializer(
561 help_text="Reference to the VirtualStorage resource.",
566 class AffectedVLsSerializer(serializers.Serializer):
567 id = serializers.UUIDField(
568 help_text="Identifier of the virtual link instance, identifying " +
569 "the applicable 'vnfVirtualLinkResourceInfo' ",
572 virtualLinkDescId = serializers.UUIDField(
573 help_text="Identifier of the related VLD in the VNFD.",
576 changeType = serializers.ChoiceField(
577 help_text="Signals the type of change",
579 choices=VLS_CHANGE_TYPES
581 metadata = serializers.DictField(
582 help_text="Metadata about this resource. ",
585 networkResource = ResourceHandleSerializer(
586 help_text="Reference to the VirtualNetwork resource.",
591 class ResourceChangesSerializer(serializers.Serializer):
592 affectedVnfcs = AffectedVnfcsSerializer(
593 help_text="Information about VNFC instances that were affected " +
594 "during the lifecycle operation.",
598 affectedVirtualLinks = AffectedVLsSerializer(
599 help_text="Information about VL instances that were affected " +
600 "during the lifecycle operation. ",
604 affectedVirtualStorages = AffectedStoragesSerializer(
605 help_text="Information about virtualised storage instances that " +
606 "were affected during the lifecycle operation",
612 class VNFLCMOpOccSerializer(serializers.Serializer):
613 id = serializers.CharField(
614 help_text="Identifier of this VNF lifecycle management operation" +
620 operationState = serializers.ChoiceField(
621 help_text="The state of the VNF LCM operation occurrence. ",
623 choices=LCM_OPERATION_STATE_TYPES
625 stateEnteredTime = serializers.CharField(
626 help_text="Date-time when the current state was entered.",
629 startTime = serializers.CharField(
630 help_text="Date-time of the start of the operation.",
633 vnfInstanceId = serializers.UUIDField(
634 help_text="Identifier of the VNF instance to which the operation" +
637 grantId = serializers.UUIDField(
638 help_text="Identifier of the grant related to this VNF LCM operation " +
639 "occurrence, if such grant exists.",
642 operation = serializers.ChoiceField(
643 help_text="The lifecycle management operation",
645 choices=LCM_OPERATION_TYPES
647 isAutomaticInvocation = serializers.BooleanField(
648 help_text="Set to true if this VNF LCM operation occurrence has " +
649 "been triggered by an automated procedure inside the VNFM. " +
650 "Set to False otherwise.",
653 operationParams = serializers.DictField(
654 help_text="Input parameters of the LCM operation. This attribute " +
655 "shall be formatted according to the request data type of the " +
656 "related LCM operation. The following mapping between operationType and the " +
657 "data type of this attribute shall apply: " +
658 "1. INSTANTIATE: InstantiateVnfRequest" +
659 "2. SCALE: ScaleVnfRequest " +
660 "3. SCALE_TO_LEVEL: ScaleVnfToLevelRequest " +
661 "4. CHANGE_FLAVOUR: ChangeVnfFlavourRequest " +
662 "5. OPERATE: OperateVnfRequest " +
663 "6. HEAL: HealVnfRequest " +
664 "7. CHANGE_EXT_CONN: ChangeExtVnfConnectivityRequest " +
665 "8. TERMINATE: TerminateVnfRequest " +
666 "9. MODIFY_INFO: VnfInfoModifications",
670 isCancelPending = serializers.BooleanField(
671 help_text="If the VNF LCM operation occurrence is in 'STARTING'" +
672 "'PROCESSING' or 'ROLLING_BACK' state and the operation is being" +
673 " cancelled, this attribute shall be set to True. Otherwise, " +
674 " it shall be set to False.",
677 cancelMode = serializers.CharField(
678 help_text="The mode of an ongoing cancellation. Shall be present " +
679 "when isCancelPending=true, and shall be None otherwise.",
683 error = ProblemDetailsSerializer(
684 help_text="If 'operationState' is 'FAILED_TEMP' or 'FAILED' or " +
685 "'PROCESSING' or 'ROLLING_BACK' and previous value of 'operationState' " +
686 "was 'FAILED_TEMP' this attribute shall be present ",
690 resourceChanges = ResourceChangesSerializer(
691 help_text="It contains information about the cumulative changes " +
692 "to virtualised resources that were performed so far by the LCM " +
693 "operation since its start, if applicable.",
696 changedInfo = VnfInfoModificationsSerializer(
697 help_text="Information about the changed VNF instance information, " +
698 "including VNF configurable properties",
701 changedExtConnectivity = ExtVirtualLinkInfoSerializer(
702 help_text="Information about changed external connectivity, if this " +
703 "notification represents the result of a lifecycle operation occurrence. " +
704 "Shall be present if the 'notificationStatus' is set to 'RESULT' and the " +
705 "'operation' is set to 'CHANGE_EXT_CONN'. Shall be absent otherwise.",
709 _links = LcmOpLinkSerializer(
710 help_text="Links to resources related to this resource.",