diff options
author | maopengzhang <zhang.maopeng1@zte.com.cn> | 2019-04-25 20:04:58 +0800 |
---|---|---|
committer | maopengzhang <zhang.maopeng1@zte.com.cn> | 2019-04-25 20:12:05 +0800 |
commit | 5f005b8bcb667b7e1635e714c4997462c6a2a4e0 (patch) | |
tree | 7bd64689596d33d2b777993125f75996184c46e7 | |
parent | 22631f12c6029a38be6cb3acdc21e6f8f6400f6c (diff) |
Add enum file for ns_vnfs
Add enum file for ns_vnfs
Change-Id: I0ca256370e2afbf69c9e027173994a7d177331a9
Issue-ID: VFC-1241
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
-rw-r--r-- | lcm/ns/biz/scaleaspect.py | 2 | ||||
-rw-r--r-- | lcm/ns/enum.py | 12 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/create_vnfs.py | 3 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/handle_notification.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/heal_vnfs.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/notify_lcm.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/scale_vnfs.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/terminate_nfs.py | 3 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/update_vnfs.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/const.py | 10 | ||||
-rw-r--r-- | lcm/ns_vnfs/enum.py | 109 | ||||
-rw-r--r-- | lcm/ns_vnfs/serializers/grant_vnf_serializer.py | 72 | ||||
-rw-r--r-- | lcm/ns_vnfs/serializers/serializers.py | 642 | ||||
-rw-r--r-- | lcm/ns_vnfs/tests/tests.py | 2 |
14 files changed, 622 insertions, 243 deletions
diff --git a/lcm/ns/biz/scaleaspect.py b/lcm/ns/biz/scaleaspect.py index 9c941817..18a45e71 100644 --- a/lcm/ns/biz/scaleaspect.py +++ b/lcm/ns/biz/scaleaspect.py @@ -20,7 +20,7 @@ import os from lcm.pub.database.models import NSInstModel from lcm.pub.database.models import NfInstModel from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import VNF_STATUS +from lcm.ns_vnfs.enum import VNF_STATUS logger = logging.getLogger(__name__) SCALE_TYPE = ("SCALE_NS", "SCALE_VNF") diff --git a/lcm/ns/enum.py b/lcm/ns/enum.py index 3db22116..e2755ec2 100644 --- a/lcm/ns/enum.py +++ b/lcm/ns/enum.py @@ -190,18 +190,6 @@ STOP_TYPE = enum( FORCEFUL="FORCEFUL", GRACEFUL="GRACEFUL" ) -VNF_STATUS = enum( - NULL='null', - INSTANTIATING="instantiating", - INACTIVE='inactive', - ACTIVE="active", - FAILED="failed", - TERMINATING="terminating", - SCALING="scaling", - OPERATING="operating", - UPDATING="updating", - HEALING="healing" -) VNF_STATE = enum( STARTED="STARTED", STOPPED="STOPPED" diff --git a/lcm/ns_vnfs/biz/create_vnfs.py b/lcm/ns_vnfs/biz/create_vnfs.py index a8ebf6d7..19f1ce53 100644 --- a/lcm/ns_vnfs/biz/create_vnfs.py +++ b/lcm/ns_vnfs/biz/create_vnfs.py @@ -32,7 +32,8 @@ from lcm.pub.utils.share_lock import do_biz_with_share_lock from lcm.pub.utils.timeutil import now_time from lcm.pub.utils.values import ignore_case_get from lcm.pub.utils import restcall -from lcm.ns_vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE, INST_TYPE_NAME +from lcm.ns_vnfs.const import NFVO_VNF_INST_TIMEOUT_SECOND +from lcm.ns_vnfs.enum import VNF_STATUS, INST_TYPE, INST_TYPE_NAME from lcm.ns_vnfs.biz.wait_job import wait_job_finish from lcm.pub.config.config import REG_TO_MSB_REG_PARAM, OOF_BASE_URL, OOF_PASSWD, OOF_USER from lcm.pub.config.config import CUST_NAME, CUST_LAT, CUST_LONG diff --git a/lcm/ns_vnfs/biz/handle_notification.py b/lcm/ns_vnfs/biz/handle_notification.py index aee6e9c8..fcc8bf0f 100644 --- a/lcm/ns_vnfs/biz/handle_notification.py +++ b/lcm/ns_vnfs/biz/handle_notification.py @@ -19,7 +19,7 @@ import uuid from rest_framework import status from rest_framework.response import Response -from lcm.ns_vnfs.const import INST_TYPE +from lcm.ns_vnfs.enum import INST_TYPE from lcm.pub.config.config import REPORT_TO_AAI from lcm.pub.database.models import (CPInstModel, NfInstModel, PortInstModel, VLInstModel, VmInstModel, VNFCInstModel) diff --git a/lcm/ns_vnfs/biz/heal_vnfs.py b/lcm/ns_vnfs/biz/heal_vnfs.py index ec0c9ddf..9b574dfa 100644 --- a/lcm/ns_vnfs/biz/heal_vnfs.py +++ b/lcm/ns_vnfs/biz/heal_vnfs.py @@ -25,7 +25,7 @@ from lcm.pub.msapi.vnfmdriver import send_nf_heal_request from lcm.pub.utils import restcall from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import VNF_STATUS +from lcm.ns_vnfs.enum import VNF_STATUS from lcm.ns_vnfs.biz.wait_job import wait_job_finish JOB_ERROR = 255 diff --git a/lcm/ns_vnfs/biz/notify_lcm.py b/lcm/ns_vnfs/biz/notify_lcm.py index 4f7ac300..e5d42a22 100644 --- a/lcm/ns_vnfs/biz/notify_lcm.py +++ b/lcm/ns_vnfs/biz/notify_lcm.py @@ -26,7 +26,7 @@ from lcm.pub.msapi.aai import create_network_aai, query_network_aai, delete_netw from lcm.pub.msapi.aai import create_vserver_aai from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import INST_TYPE +from lcm.ns_vnfs.enum import INST_TYPE logger = logging.getLogger(__name__) diff --git a/lcm/ns_vnfs/biz/scale_vnfs.py b/lcm/ns_vnfs/biz/scale_vnfs.py index bac181ec..c405a40c 100644 --- a/lcm/ns_vnfs/biz/scale_vnfs.py +++ b/lcm/ns_vnfs/biz/scale_vnfs.py @@ -21,7 +21,7 @@ from lcm.pub.exceptions import NSLCMException from lcm.pub.msapi.vnfmdriver import send_nf_scaling_request from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import VNF_STATUS +from lcm.ns_vnfs.enum import VNF_STATUS from lcm.ns_vnfs.biz.wait_job import wait_job_finish JOB_ERROR = 255 diff --git a/lcm/ns_vnfs/biz/terminate_nfs.py b/lcm/ns_vnfs/biz/terminate_nfs.py index 073f2562..4ab624b7 100644 --- a/lcm/ns_vnfs/biz/terminate_nfs.py +++ b/lcm/ns_vnfs/biz/terminate_nfs.py @@ -26,7 +26,8 @@ from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id from lcm.pub.msapi.vnfmdriver import send_nf_terminate_request from lcm.pub.utils.jobutil import JOB_MODEL_STATUS, JobUtil from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE +from lcm.ns_vnfs.const import NFVO_VNF_INST_TIMEOUT_SECOND +from lcm.ns_vnfs.enum import VNF_STATUS, INST_TYPE from lcm.ns_vnfs.biz.wait_job import wait_job_finish from lcm.ns_vnfs.biz.subscribe import SubscriptionDeletion diff --git a/lcm/ns_vnfs/biz/update_vnfs.py b/lcm/ns_vnfs/biz/update_vnfs.py index 7a58b359..a4073f18 100644 --- a/lcm/ns_vnfs/biz/update_vnfs.py +++ b/lcm/ns_vnfs/biz/update_vnfs.py @@ -22,7 +22,7 @@ from lcm.pub.exceptions import NSLCMException from lcm.pub.msapi.vnfmdriver import send_nf_operate_request from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS from lcm.pub.utils.values import ignore_case_get -from lcm.ns_vnfs.const import VNF_STATUS +from lcm.ns_vnfs.enum import VNF_STATUS from lcm.ns_vnfs.biz.wait_job import wait_job_finish JOB_ERROR = 255 diff --git a/lcm/ns_vnfs/const.py b/lcm/ns_vnfs/const.py index 0c831dca..4a67826b 100644 --- a/lcm/ns_vnfs/const.py +++ b/lcm/ns_vnfs/const.py @@ -11,14 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from lcm.pub.utils.enumutil import enum - -VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active", FAILED="failed", - TERMINATING="terminating", SCALING="scaling", HEALING="healing", UPDATING="updating") -INST_TYPE = enum(VNF=0, VNFM=1) -INST_TYPE_NAME = enum(VNF='VNF', VNFM='VNFM') -PACKAGE_TYPE = enum(VNFD='VNFD', NSD='NSD') - -NFVO_VNF_INST_TIMEOUT_SECOND = 3000 DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S' +NFVO_VNF_INST_TIMEOUT_SECOND = 3000 diff --git a/lcm/ns_vnfs/enum.py b/lcm/ns_vnfs/enum.py new file mode 100644 index 00000000..3edc5568 --- /dev/null +++ b/lcm/ns_vnfs/enum.py @@ -0,0 +1,109 @@ +# Copyright 2019 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from lcm.pub.utils.enumutil import enum + +CANDIDATE_IDENTIFIER_TYPE = enum( + SERVICE_INSTANCE_ID="serviceInstanceId", + VNF_NAME="vnfName", + CLOUD_REGION_ID="cloudRegionId", + VIM_ID="vimId" +) +GRANT_OPERATION = enum( + INSTANTIATE="INSTANTIATE", + SCALE="SCALE", + SCALE_TO_LEVEL="SCALE_TO_LEVEL", + CHANGE_FLAVOUR="CHANGE_FLAVOUR", + TERMINATE="TERMINATE", + HEAL="HEAL", + OPERATE="OPERATE", + CHANGE_EXT_CONN="CHANGE_EXT_CONN", + MODIFY_INFO="MODIFY_INFO" +) +INST_TYPE = enum( + VNF=0, + VNFM=1) +INST_TYPE_NAME = enum( + VNF="VNF", + VNFM="VNFM") +LIFE_CYCLE_OPERATION = enum( + TERMINATE="Terminate", + INSTANTIATE="Instantiate", + SCALEIN="Scalein", + SCALEOUT="Scaleout", + SCALEDOWN="Scaledown", + SCALEUP="Scaleup", + HEAL="Heal" +) +NETWORK_RESOURCE_TYPE = enum( + NETWORK="network", + PORT="port" +) +PLACE_VNF_REQUEST_STATUS = enum( + COMPLETED="completed", + FAILED="failed", + PENDING="pending" +) +RESOURCE_CHANGE_TYPE = enum( + VDU="VDU" +) +RESOURE_TYPE = enum( + COMPUTE="COMPUTE", + VL="VL", + STORAGE="STORAGE", + LINKPORT="LINKPORT" +) +RESOURCE_ID_TYPE = enum( + RES_MGMT="RES_MGMT", + GRANT="GRANT" +) +SCALE_VNF_TYPE = enum( + SCALE_IN="SCALE_IN", + SCALE_OUT="SCALE_OUT" +) +STORAGE_CHANGE_TYPE = enum( + ADDED="ADDED", + MODIFIED="MODIFIED", + REMOVED="REMOVED", + TEMPORARY="TEMPORARY" +) +VL_CHANGE_TYPE = enum( + ADDED="ADDED", + REMOVED="REMOVED", + MODIFIED="MODIFIED", + TEMPORARY="TEMPORARY", + LINK_PORT_ADDED="LINK_PORT_ADDED", + LINK_PORT_REMOVED="LINK_PORT_REMOVED" +) +VNF_NOTIFICATION_TYPE = enum( + VNFLCMOPERATIONOCCURRENCENOTIFICATION="VnfLcmOperationOccurrenceNotification", + VnfIdentifierCreationNotification="VnfIdentifierCreationNotification", + VnfIdentifierDeletionNotification="VnfIdentifierDeletionNotification" +) +VNF_STATUS = enum( + NULL="null", + INSTANTIATING="instantiating", + INACTIVE="inactive", + ACTIVE="active", + FAILED="failed", + TERMINATING="terminating", + SCALING="scaling", + HEALING="healing", + UPDATING="updating" +) +VNFC_CHANGE_TYPE = enum( + ADDED="ADDED", + MODIFIED="MODIFIED", + REMOVED="REMOVED", + TEMPORARY="TEMPORARY" +) diff --git a/lcm/ns_vnfs/serializers/grant_vnf_serializer.py b/lcm/ns_vnfs/serializers/grant_vnf_serializer.py index 98e50399..fb81609f 100644 --- a/lcm/ns_vnfs/serializers/grant_vnf_serializer.py +++ b/lcm/ns_vnfs/serializers/grant_vnf_serializer.py @@ -18,31 +18,9 @@ from lcm.ns.serializers.sol.ext_virtual_link_info import ExtVirtualLinkInfoSeria from lcm.ns.serializers.sol.cp_serializers import AddressRangeSerializer from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer, LinkSerializer - - -# class ResourceHandleSerializer(serializers.Serializer): -# vimConnectionId = serializers.CharField( -# help_text="Identifier of the VIM connection to manage the resource.", -# required=False, -# allow_null=True, -# allow_blank=True -# ) -# resourceProviderId = serializers.CharField( -# help_text="Identifier of the entity responsible for the management of the resource.", -# required=False, -# allow_null=True, -# allow_blank=True -# ) -# resourceId = serializers.CharField( -# help_text="Identifier of the resource in the scope of the VIM or the resource provider.", -# required=True -# ) -# vimLevelResourceType = serializers.CharField( -# help_text="Type of the resource in the scope of the VIM or the resource provider.", -# required=False, -# allow_null=True, -# allow_blank=True -# ) +from lcm.ns.enum import LAYER_PROTOCOL, IPADDRESSES_TYPE, AFFINITY_OR_ANTIAFFIINTY_SCOPE, AFFINITY_OR_ANTIAFFIINTY, LCM_NOTIFICATION_STATUS, OPERATION_STATE_TYPE +from lcm.ns_vnfs.enum import STORAGE_CHANGE_TYPE, VNFC_CHANGE_TYPE, VL_CHANGE_TYPE, RESOURE_TYPE, RESOURCE_ID_TYPE, GRANT_OPERATION, VNF_NOTIFICATION_TYPE +from lcm.pub.utils.enumutil import enum_to_list class ResourceDefinitionSerializer(serializers.Serializer): @@ -52,7 +30,7 @@ class ResourceDefinitionSerializer(serializers.Serializer): ) type = serializers.ChoiceField( help_text="Type of the resource definition referenced.", - choices=["COMPUTE", "VL", "STORAGE", "LINKPORT"], + choices=enum_to_list(RESOURE_TYPE), required=True ) vduId = serializers.CharField( @@ -77,7 +55,7 @@ class ResourceDefinitionSerializer(serializers.Serializer): class ConstraintResourceRefSerializer(serializers.Serializer): idType = serializers.ChoiceField( help_text="The type of the identifier.", - choices=["RES_MGMT", "GRANT"], + choices=enum_to_list(RESOURCE_ID_TYPE), required=True ) resourceId = serializers.CharField( @@ -101,12 +79,12 @@ class ConstraintResourceRefSerializer(serializers.Serializer): class PlacementConstraintSerializer(serializers.Serializer): affinityOrAntiAffinity = serializers.ChoiceField( help_text="The type of the constraint.", - choices=["AFFINITY", "ANTI_AFFINITY"], + choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY), required=True ) scope = serializers.ChoiceField( help_text="The scope of the placement constraint indicating the category of the place where the constraint applies.", - choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"], + choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY_SCOPE), required=True ) resource = ConstraintResourceRefSerializer( @@ -171,7 +149,7 @@ class GrantRequestSerializer(serializers.Serializer): ) operation = serializers.ChoiceField( help_text="The lifecycle management operation for which granting is requested.", - choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"], + choices=enum_to_list(GRANT_OPERATION), required=True ) isAutomaticInvocation = serializers.BooleanField( @@ -415,7 +393,7 @@ class VimAssetsSerializer(serializers.Serializer): class IpAddresseSerializer(serializers.Serializer): type = serializers.ChoiceField( help_text="The type of the IP addresses.", - choices=["IPV4", "IPV6"], + choices=enum_to_list(IPADDRESSES_TYPE), required=True ) fixedAddresses = serializers.ListSerializer( @@ -458,7 +436,7 @@ class IpOverEthernetAddressSerializer(serializers.Serializer): class CpProtocolDataConfigSerializer(serializers.Serializer): layerProtocol = serializers.ChoiceField( help_text="Identifier of layer(s) and protocol(s).", - choices=["IP_OVER_ETHERNET"], + choices=enum_to_list(LAYER_PROTOCOL), required=True ) ipOverEthernet = IpOverEthernetAddressSerializer( @@ -693,7 +671,7 @@ class AffectedVnfcSerializer(serializers.Serializer): ) changeType = serializers.ChoiceField( help_text="Signals the type of change.", - choices=["ADDED", "REMOVED", "MODIFIED", "TEMPORARY"], + choices=enum_to_list(VNFC_CHANGE_TYPE), required=True ) computeResource = ResourceHandleSerializer( @@ -737,7 +715,7 @@ class AffectedVirtualLinkSerializer(serializers.Serializer): ) changeType = serializers.ChoiceField( help_text="Signals the type of change.", - choices=["ADDED", "REMOVED", "MODIFIED", "TEMPORARY", "LINK_PORT_ADDED", "LINK_PORT_REMOVED"], + choices=enum_to_list(VL_CHANGE_TYPE), required=True ) networkResource = ResourceHandleSerializer( @@ -764,7 +742,7 @@ class AffectedVirtualStorageSerializer(serializers.Serializer): ) changeType = serializers.ChoiceField( help_text="Signals the type of change.", - choices=["ADDED", "REMOVED", "MODIFIED", "TEMPORARY"], + choices=enum_to_list(STORAGE_CHANGE_TYPE), required=True ) storageResource = ResourceHandleSerializer( @@ -939,11 +917,7 @@ class VnfLcmOperationOccurrenceNotificationSerializer(serializers.Serializer): ) notificationType = serializers.ChoiceField( help_text="Discriminator for the different notification types.", - choices=[ - 'VnfLcmOperationOccurrenceNotification', - 'VnfIdentifierCreationNotification', - 'VnfIdentifierDeletionNotification' - ], + choices=enum_to_list(VNF_NOTIFICATION_TYPE), required=True ) subscriptionId = serializers.CharField( @@ -956,12 +930,12 @@ class VnfLcmOperationOccurrenceNotificationSerializer(serializers.Serializer): ) notificationStatus = serializers.ChoiceField( help_text="Indicates whether this notification reports about the start of a lifecycle operation or the result of a lifecycle operation.", - choices=["START", "RESULT"], + choices=enum_to_list(LCM_NOTIFICATION_STATUS), required=True ) operationState = serializers.ChoiceField( help_text="The state of the VNF LCM operation occurrence.", - choices=["STARTING", "PROCESSING", "COMPLETED", "FAILED_TEMP", "FAILED", "ROLLING_BACK", "ROLLED_BACK"], + choices=enum_to_list(OPERATION_STATE_TYPE), required=True ) vnfInstanceId = serializers.CharField( @@ -970,7 +944,7 @@ class VnfLcmOperationOccurrenceNotificationSerializer(serializers.Serializer): ) operation = serializers.ChoiceField( help_text="The lifecycle management operation.", - choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"], + choices=enum_to_list(GRANT_OPERATION), required=True ) isAutomaticInvocation = serializers.BooleanField( @@ -1029,11 +1003,7 @@ class VnfIdentifierCreationNotificationSerializer(serializers.Serializer): ) notificationType = serializers.ChoiceField( help_text="Discriminator for the different notification types.", - choices=[ - 'VnfLcmOperationOccurrenceNotification', - 'VnfIdentifierCreationNotification', - 'VnfIdentifierDeletionNotification' - ], + choices=enum_to_list(VNF_NOTIFICATION_TYPE), required=True ) subscriptionId = serializers.CharField( @@ -1071,11 +1041,7 @@ class VnfIdentifierDeletionNotificationSerializer(serializers.Serializer): ) notificationType = serializers.ChoiceField( help_text="Discriminator for the different notification types.", - choices=[ - 'VnfLcmOperationOccurrenceNotification', - 'VnfIdentifierCreationNotification', - 'VnfIdentifierDeletionNotification' - ], + choices=enum_to_list(VNF_NOTIFICATION_TYPE), required=True ) subscriptionId = serializers.CharField( diff --git a/lcm/ns_vnfs/serializers/serializers.py b/lcm/ns_vnfs/serializers/serializers.py index dbb566ea..1f0f49b4 100644 --- a/lcm/ns_vnfs/serializers/serializers.py +++ b/lcm/ns_vnfs/serializers/serializers.py @@ -13,136 +13,297 @@ # limitations under the License. from rest_framework import serializers +from lcm.pub.utils.enumutil import enum_to_list +from lcm.ns.enum import LCM_NOTIFICATION_STATUS +from lcm.ns_vnfs.enum import RESOURCE_CHANGE_TYPE, LIFE_CYCLE_OPERATION, VNFC_CHANGE_TYPE, NETWORK_RESOURCE_TYPE, SCALE_VNF_TYPE, CANDIDATE_IDENTIFIER_TYPE, PLACE_VNF_REQUEST_STATUS class InstVnfReqSerializer(serializers.Serializer): - vnfIndex = serializers.CharField(help_text="Index of VNF", required=True) - nsInstanceId = serializers.CharField(help_text="ID of NS instance", required=True) - additionalParamForVnf = serializers.CharField(help_text="Additional param for VNF", required=False, allow_null=True, allow_blank=True) + vnfIndex = serializers.CharField( + help_text="Index of VNF", + required=True) + nsInstanceId = serializers.CharField( + help_text="ID of NS instance", + required=True) + additionalParamForVnf = serializers.CharField( + help_text="Additional param for VNF", + required=False, + allow_null=True, + allow_blank=True) class InstVnfRespSerializer(serializers.Serializer): - vnfInstId = serializers.CharField(help_text="ID of VNF instance", required=True) - jobId = serializers.CharField(help_text="ID of Job", required=True) + vnfInstId = serializers.CharField( + help_text="ID of VNF instance", + required=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=True) class VnfVmsSerializer(serializers.Serializer): - vmID = serializers.CharField(help_text="ID of VM", required=True) - vmName = serializers.CharField(help_text="Name of VM", required=False, allow_null=True, allow_blank=True) + vmID = serializers.CharField( + help_text="ID of VM", + required=True) + vmName = serializers.CharField( + help_text="Name of VM", + required=False, + allow_null=True, + allow_blank=True) class GetVnfRespSerializer(serializers.Serializer): - vnfInstId = serializers.CharField(help_text="ID of VNF instance", required=True) - vnfName = serializers.CharField(help_text="Name of VNF instance", required=True) - vnfStatus = serializers.CharField(help_text="Status of VNF instance", required=True) - vnfVms = VnfVmsSerializer(help_text="VMs of VNF", many=True) + vnfInstId = serializers.CharField( + help_text="ID of VNF instance", + required=True) + vnfName = serializers.CharField( + help_text="Name of VNF instance", + required=True) + vnfStatus = serializers.CharField( + help_text="Status of VNF instance", + required=True) + vnfVms = VnfVmsSerializer( + help_text="VMs of VNF", + many=True) class TerminateVnfReqSerializer(serializers.Serializer): - terminationType = serializers.CharField(help_text="Termination Type", required=False, allow_null=True) - gracefulTerminationTimeout = serializers.CharField(help_text="Graceful Termination Timeout", required=False, allow_null=True, allow_blank=True) + terminationType = serializers.CharField( + help_text="Termination Type", + required=False, + allow_null=True) + gracefulTerminationTimeout = serializers.CharField( + help_text="Graceful Termination Timeout", + required=False, + allow_null=True, + allow_blank=True) class TerminateVnfRespSerializer(serializers.Serializer): - jobId = serializers.CharField(help_text="ID of Job", required=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=True) class ResourceChangeSerializer(serializers.Serializer): - type = serializers.ChoiceField(help_text="Change Type", choices=["VDU"], required=True) - resourceDefinitionId = serializers.CharField(help_text="Identifier of resource", required=False, allow_null=True, allow_blank=True) - vdu = serializers.CharField(help_text="Identifier identifier of VDU", required=False, allow_null=True, allow_blank=True) + type = serializers.ChoiceField( + help_text="Change Type", + choices=enum_to_list(RESOURCE_CHANGE_TYPE), + required=True) + resourceDefinitionId = serializers.CharField( + help_text="Identifier of resource", + required=False, + allow_null=True, + allow_blank=True) + vdu = serializers.CharField( + help_text="Identifier identifier of VDU", + required=False, + allow_null=True, + allow_blank=True) class GrantVnfReqSerializer(serializers.Serializer): - vnfInstanceId = serializers.CharField(help_text="ID of VNF instance", required=True) - vnfDescriptorId = serializers.CharField(help_text="ID of VNF Descriptor", required=False, allow_null=True, allow_blank=True) + vnfInstanceId = serializers.CharField( + help_text="ID of VNF instance", + required=True) + vnfDescriptorId = serializers.CharField( + help_text="ID of VNF Descriptor", + required=False, + allow_null=True, + allow_blank=True) lifecycleOperation = serializers.ChoiceField( help_text="Lifecycle Operation", - choices=["Terminate", "Instantiate", "Scalein", "Scaleout", "Scaledown", "Scaleup", "Heal"], - required=True - ) - jobId = serializers.CharField(help_text="ID of Job", required=False, allow_null=True, allow_blank=True) - addResource = ResourceChangeSerializer(help_text="Add resources", many=True) - removeResource = ResourceChangeSerializer(help_text="Remove resources", many=True) + choices=enum_to_list(LIFE_CYCLE_OPERATION), + required=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=False, + allow_null=True, + allow_blank=True) + addResource = ResourceChangeSerializer( + help_text="Add resources", + many=True) + removeResource = ResourceChangeSerializer( + help_text="Remove resources", + many=True) additionalParam = serializers.DictField( help_text="Additional parameters passed to the NFVO, specific to the VNF and the LCM operation. The currently interpreted keys are the following: vimId", child=serializers.CharField(help_text="Additional parameters", allow_blank=True), required=False, - allow_null=True - ) + allow_null=True) class AccessinfoSerializer(serializers.Serializer): - tenant = serializers.CharField(help_text="Name of tenant", required=True) + tenant = serializers.CharField( + help_text="Name of tenant", + required=True) class VimSerializer(serializers.Serializer): - vimid = serializers.CharField(help_text="ID of VIM", required=True) - accessinfo = AccessinfoSerializer(help_text="Access Info", required=False) - accessInfo = AccessinfoSerializer(help_text="Access Info", required=False) + vimid = serializers.CharField( + help_text="ID of VIM", + required=True) + accessinfo = AccessinfoSerializer( + help_text="Access Info", + required=False) + accessInfo = AccessinfoSerializer( + help_text="Access Info", + required=False) class GrantVnfRespSerializer(serializers.Serializer): - vnfInstanceId = serializers.CharField(help_text="ID of VNF instance", required=False, allow_null=True, allow_blank=True) - vim = VimSerializer(help_text="VIM Info", required=True) + vnfInstanceId = serializers.CharField( + help_text="ID of VNF instance", + required=False, + allow_null=True, + allow_blank=True) + vim = VimSerializer( + help_text="VIM Info", + required=True) class AffectedVnfcLcmSerializer(serializers.Serializer): - vnfcInstanceId = serializers.CharField(help_text="ID of VNFC instance", required=False, allow_null=True, allow_blank=True) - vduId = serializers.CharField(help_text="ID of VDU in VNFD", required=False, allow_null=True, allow_blank=True) + vnfcInstanceId = serializers.CharField( + help_text="ID of VNFC instance", + required=False, + allow_null=True, + allow_blank=True) + vduId = serializers.CharField( + help_text="ID of VDU in VNFD", + required=False, + allow_null=True, + allow_blank=True) changeType = serializers.ChoiceField( help_text="Type of Change", - choices=["added", "removed", "modified"], - required=True - ) - vimId = serializers.CharField(help_text="ID of VIM", required=False, allow_null=True, allow_blank=True) - vmId = serializers.CharField(help_text="ID of virtual machine", required=False, allow_null=True, allow_blank=True) - vmName = serializers.CharField(help_text="Name of virtual machine", required=False, allow_null=True, allow_blank=True) + choices=enum_to_list(VNFC_CHANGE_TYPE), # ["added", "removed", "modified"], + required=True) + vimId = serializers.CharField( + help_text="ID of VIM", + required=False, + allow_null=True, + allow_blank=True) + vmId = serializers.CharField( + help_text="ID of virtual machine", + required=False, + allow_null=True, + allow_blank=True) + vmName = serializers.CharField( + help_text="Name of virtual machine", + required=False, + allow_null=True, + allow_blank=True) class NetworkResourceSerializer(serializers.Serializer): resourceType = serializers.ChoiceField( help_text="Type of Resource", - choices=["network", "port"], - required=True - ) - resourceId = serializers.CharField(help_text="ID of network resource", required=False, allow_null=True, allow_blank=True) - resourceName = serializers.CharField(help_text="Name of network resource", required=False, allow_null=True, allow_blank=True) + choices=enum_to_list(NETWORK_RESOURCE_TYPE), + required=True) + resourceId = serializers.CharField( + help_text="ID of network resource", + required=False, + allow_null=True, + allow_blank=True) + resourceName = serializers.CharField( + help_text="Name of network resource", + required=False, + allow_null=True, + allow_blank=True) class AffectedVirtualLinkLcmSerializer(serializers.Serializer): - vlInstanceId = serializers.CharField(help_text="ID of VL instance", required=False, allow_null=True, allow_blank=True) - vldId = serializers.CharField(help_text="ID of VLD in VNFD", required=False, allow_null=True, allow_blank=True) + vlInstanceId = serializers.CharField( + help_text="ID of VL instance", + required=False, + allow_null=True, + allow_blank=True) + vldId = serializers.CharField( + help_text="ID of VLD in VNFD", + required=False, + allow_null=True, + allow_blank=True) changeType = serializers.ChoiceField( help_text="Type of Change", - choices=["added", "removed", "modified"], - required=True - ) - networkResource = NetworkResourceSerializer(help_text="Network Resource", required=False, allow_null=True) + choices=enum_to_list(VNFC_CHANGE_TYPE), # ["added", "removed", "modified"], + required=True) + networkResource = NetworkResourceSerializer( + help_text="Network Resource", + required=False, + allow_null=True) class PortResourceSerializer(serializers.Serializer): - vimId = serializers.CharField(help_text="ID of VIM", required=False, allow_null=True, allow_blank=True) - resourceId = serializers.CharField(help_text="ID of Resource", required=False, allow_null=True, allow_blank=True) - resourceName = serializers.CharField(help_text="Name of Resource", required=False, allow_null=True, allow_blank=True) - tenant = serializers.CharField(help_text="ID of Tenant", required=False, allow_null=True, allow_blank=True) - ipAddress = serializers.CharField(help_text="IP address of port", required=False, allow_null=True, allow_blank=True) - macAddress = serializers.CharField(help_text="MAC address of port", required=False, allow_null=True, allow_blank=True) - instId = serializers.CharField(help_text="Instance id of server to which the port is attached to", required=False, allow_null=True, allow_blank=True) + vimId = serializers.CharField( + help_text="ID of VIM", + required=False, + allow_null=True, + allow_blank=True) + resourceId = serializers.CharField( + help_text="ID of Resource", + required=False, + allow_null=True, + allow_blank=True) + resourceName = serializers.CharField( + help_text="Name of Resource", + required=False, + allow_null=True, + allow_blank=True) + tenant = serializers.CharField( + help_text="ID of Tenant", + required=False, + allow_null=True, + allow_blank=True) + ipAddress = serializers.CharField( + help_text="IP address of port", + required=False, + allow_null=True, + allow_blank=True) + macAddress = serializers.CharField( + help_text="MAC address of port", + required=False, + allow_null=True, + allow_blank=True) + instId = serializers.CharField( + help_text="Instance id of server to which the port is attached to", + required=False, + allow_null=True, + allow_blank=True) class AffectedCpSerializer(serializers.Serializer): changeType = serializers.ChoiceField( help_text="Type of Change", - choices=["added", "removed", "modified"], - required=True - ) - virtualLinkInstanceId = serializers.CharField(help_text="ID of VL instance", required=False, allow_null=True, allow_blank=True) - cpInstanceId = serializers.CharField(help_text="ID of CP instance", required=False, allow_null=True, allow_blank=True) - cpdId = serializers.CharField(help_text="ID of CPD in VNFD", required=False, allow_null=True, allow_blank=True) - ownerType = serializers.CharField(help_text="Type of Owner", required=False, allow_null=True, allow_blank=True) - ownerId = serializers.CharField(help_text="ID of Owner", required=False, allow_null=True, allow_blank=True) - portResource = PortResourceSerializer(help_text="Port Resource", required=False, allow_null=True) + choices=enum_to_list(VNFC_CHANGE_TYPE), # ["added", "removed", "modified"], + required=True) + virtualLinkInstanceId = serializers.CharField( + help_text="ID of VL instance", + required=False, + allow_null=True, + allow_blank=True) + cpInstanceId = serializers.CharField( + help_text="ID of CP instance", + required=False, + allow_null=True, + allow_blank=True) + cpdId = serializers.CharField( + help_text="ID of CPD in VNFD", + required=False, + allow_null=True, + allow_blank=True) + ownerType = serializers.CharField( + help_text="Type of Owner", + required=False, + allow_null=True, + allow_blank=True) + ownerId = serializers.CharField( + help_text="ID of Owner", + required=False, + allow_null=True, + allow_blank=True) + portResource = PortResourceSerializer( + help_text="Port Resource", + required=False, + allow_null=True) class AffectedVirtualStorageLcm(serializers.Serializer): @@ -152,166 +313,327 @@ class AffectedVirtualStorageLcm(serializers.Serializer): class NotifyLcmReqSerializer(serializers.Serializer): status = serializers.ChoiceField( help_text="Status of operation", - choices=["result", "start"], + choices=enum_to_list(LCM_NOTIFICATION_STATUS), required=True ) operation = serializers.ChoiceField( help_text="Lifecycle Operation", - choices=["Terminate", "Instantiate", "Scalein", "Scaleout", "Scaledown", "Scaleup", "Heal"], + choices=enum_to_list(LIFE_CYCLE_OPERATION), required=True ) - jobId = serializers.CharField(help_text="ID of Job", required=False, allow_null=True, allow_blank=True) - vnfdmodule = serializers.CharField(help_text="VNFD Module", required=False, allow_null=True, allow_blank=True) - affectedVnfc = AffectedVnfcLcmSerializer(help_text="Affected VNFC", many=True) - affectedVl = AffectedVirtualLinkLcmSerializer(help_text="Affected VL", many=True) - affectedCp = AffectedCpSerializer(help_text="Affected CP", many=True) - affectedVirtualStorage = AffectedVirtualStorageLcm(help_text="Affected Virtual Storage(Not supported)", many=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=False, + allow_null=True, + allow_blank=True) + vnfdmodule = serializers.CharField( + help_text="VNFD Module", + required=False, + allow_null=True, + allow_blank=True) + affectedVnfc = AffectedVnfcLcmSerializer( + help_text="Affected VNFC", + many=True) + affectedVl = AffectedVirtualLinkLcmSerializer( + help_text="Affected VL", + many=True) + affectedCp = AffectedCpSerializer( + help_text="Affected CP", + many=True) + affectedVirtualStorage = AffectedVirtualStorageLcm( + help_text="Affected Virtual Storage(Not supported)", + many=True) class ScaleVnfDataSerializer(serializers.Serializer): type = serializers.ChoiceField( help_text="Direction of the scaling", - choices=["SCALE_IN", "SCALE_OUT"], - required=True - ) - aspectId = serializers.CharField(help_text="Aspect ID of the VNF that is requested to be scaled", required=False, allow_null=True, allow_blank=True) - numberOfSteps = serializers.CharField(help_text="Number of scaling steps to be executed as part of this ScaleVnf operation", required=False, allow_null=True, allow_blank=True) + choices=enum_to_list(SCALE_VNF_TYPE), + required=True) + aspectId = serializers.CharField( + help_text="Aspect ID of the VNF that is requested to be scaled", + required=False, + allow_null=True, + allow_blank=True) + numberOfSteps = serializers.CharField( + help_text="Number of scaling steps to be executed as part of this ScaleVnf operation", + required=False, + allow_null=True, + allow_blank=True) additionalParam = serializers.DictField( help_text="Additional parameters passed by the NFVO as input to the scaling process, specific to the VNF being scaled", - child=serializers.CharField(help_text="Additional parameters", allow_blank=True), + child=serializers.CharField( + help_text="Additional parameters", + allow_blank=True), required=False, allow_null=True ) class ScaleVnfReqSerializer(serializers.Serializer): - scaleVnfData = ScaleVnfDataSerializer(help_text="Scale data", many=False) + scaleVnfData = ScaleVnfDataSerializer( + help_text="Scale data", + many=False) class ScaleVnfRespSerializer(serializers.Serializer): - jobId = serializers.CharField(help_text="ID of Job", required=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=True) class VerifyVnfReqSerializer(serializers.Serializer): - PackageID = serializers.CharField(help_text="ID of Package", required=True) + PackageID = serializers.CharField( + help_text="ID of Package", + required=True) class VerifyVnfRespSerializer(serializers.Serializer): - jobId = serializers.CharField(help_text="ID of Job", required=True) + jobId = serializers.CharField( + help_text="ID of Job", + required=True) class VnfmInfoRespSerializer(serializers.Serializer): - vnfmId = serializers.CharField(help_text="ID of VNFM", required=True) - name = serializers.CharField(help_text="Name of VNFM", required=True) - type = serializers.CharField(help_text="Type of VNFM", required=True) - vimId = serializers.CharField(help_text="ID of VIM", required=True) - vendor = serializers.CharField(help_text="Vendor of VNFM", required=False, allow_null=True, allow_blank=True) - version = serializers.CharField(help_text="Version of VNFM", required=False, allow_null=True, allow_blank=True) - description = serializers.CharField(help_text="Description of VNFM", required=False, allow_null=True, allow_blank=True) - certificateUrl = serializers.CharField(help_text="Certificate PEM of VNFM", required=False, allow_null=True, allow_blank=True) - url = serializers.CharField(help_text="url of VNFM", required=False, allow_null=True, allow_blank=True) - userName = serializers.CharField(help_text="User Name of VNFM", required=False, allow_null=True, allow_blank=True) - password = serializers.CharField(help_text="Password of VNFM", required=False, allow_null=True, allow_blank=True) - createTime = serializers.CharField(help_text="Create Time of VNFM", required=False, allow_null=True, allow_blank=True) + vnfmId = serializers.CharField( + help_text="ID of VNFM", + required=True) + name = serializers.CharField( + help_text="Name of VNFM", + required=True) + type = serializers.CharField( + help_text="Type of VNFM", + required=True) + vimId = serializers.CharField( + help_text="ID of VIM", + required=True) + vendor = serializers.CharField( + help_text="Vendor of VNFM", + required=False, + allow_null=True, + allow_blank=True) + version = serializers.CharField( + help_text="Version of VNFM", + required=False, + allow_null=True, + allow_blank=True) + description = serializers.CharField( + help_text="Description of VNFM", + required=False, + allow_null=True, + allow_blank=True) + certificateUrl = serializers.CharField( + help_text="Certificate PEM of VNFM", + required=False, + allow_null=True, + allow_blank=True) + url = serializers.CharField( + help_text="url of VNFM", + required=False, + allow_null=True, + allow_blank=True) + userName = serializers.CharField( + help_text="User Name of VNFM", + required=False, + allow_null=True, + allow_blank=True) + password = serializers.CharField( + help_text="Password of VNFM", + required=False, + allow_null=True, + allow_blank=True) + createTime = serializers.CharField( + help_text="Create Time of VNFM", + required=False, + allow_null=True, + allow_blank=True) class VimInfoRespSerializer(serializers.Serializer): - vimId = serializers.CharField(help_text="ID of VIM", required=True) - name = serializers.CharField(help_text="Name of VIM", required=True) - url = serializers.CharField(help_text="Url of VIM", required=True) - userName = serializers.CharField(help_text="User Name of VIM", required=True) - password = serializers.CharField(help_text="Password of VIM", required=True) - tenantId = serializers.CharField(help_text="Tenant ID of VIM", required=False, allow_null=True, allow_blank=True) - tenant = serializers.CharField(help_text="Default Tenant of VIM", required=False, allow_null=True, allow_blank=True) - vendor = serializers.CharField(help_text="Vendor of VIM", required=False, allow_null=True, allow_blank=True) - version = serializers.CharField(help_text="Version of VIM", required=False, allow_null=True, allow_blank=True) - description = serializers.CharField(help_text="Description of VIM", required=False, allow_null=True, allow_blank=True) - domain = serializers.CharField(help_text="Domain of VIM", required=False, allow_null=True, allow_blank=True) - type = serializers.CharField(help_text="Type of VIM", required=True) - createTime = serializers.CharField(help_text="Create Time of VIM", required=False, allow_null=True, allow_blank=True) - sslCacert = serializers.CharField(help_text="SSL Cacert of VIM", required=False, allow_null=True, allow_blank=True) - sslInsecure = serializers.CharField(help_text="SSL Insecure of VIM", required=False, allow_null=True, allow_blank=True) - status = serializers.CharField(help_text="Status of VIM", required=False, allow_null=True, allow_blank=True) + vimId = serializers.CharField( + help_text="ID of VIM", + required=True) + name = serializers.CharField( + help_text="Name of VIM", + required=True) + url = serializers.CharField( + help_text="Url of VIM", + required=True) + userName = serializers.CharField( + help_text="User Name of VIM", + required=True) + password = serializers.CharField( + help_text="Password of VIM", + required=True) + tenantId = serializers.CharField( + help_text="Tenant ID of VIM", + required=False, + allow_null=True, + allow_blank=True) + tenant = serializers.CharField( + help_text="Default Tenant of VIM", + required=False, + allow_null=True, allow_blank=True) + vendor = serializers.CharField( + help_text="Vendor of VIM", + required=False, + allow_null=True, + allow_blank=True) + version = serializers.CharField( + help_text="Version of VIM", + required=False, + allow_null=True, + allow_blank=True) + description = serializers.CharField( + help_text="Description of VIM", + required=False, + allow_null=True, + allow_blank=True) + domain = serializers.CharField( + help_text="Domain of VIM", + required=False, + allow_null=True, + allow_blank=True) + type = serializers.CharField( + help_text="Type of VIM", + required=True) + createTime = serializers.CharField( + help_text="Create Time of VIM", + required=False, + allow_null=True, + allow_blank=True) + sslCacert = serializers.CharField( + help_text="SSL Cacert of VIM", + required=False, + allow_null=True, + allow_blank=True) + sslInsecure = serializers.CharField( + help_text="SSL Insecure of VIM", + required=False, + allow_null=True, + allow_blank=True) + status = serializers.CharField( + help_text="Status of VIM", + required=False, + allow_null=True, + allow_blank=True) class CandidateSerializer(serializers.Serializer): identifierType = serializers.ChoiceField( help_text="The type of a candidate", - choices=["serviceInstanceId", "vnfName", "cloudRegionId", "vimId"], - required=True - ) + choices=enum_to_list(CANDIDATE_IDENTIFIER_TYPE), + required=True) identifiers = serializers.ListField( help_text="A list of identifiers", - child=serializers.CharField(help_text="One identifier", required=True), - required=True - ) + child=serializers.CharField( + help_text="One identifier", + required=True), + required=True) cloudOwner = serializers.CharField( - help_text="The name of a cloud owner. Only required if identifier Type is cloudRegionId", required=False, allow_null=True, allow_blank=True) + help_text="The name of a cloud owner. Only required if identifier Type is cloudRegionId", + required=False, + allow_null=True, + allow_blank=True) class LicenseSolutionSerializer(serializers.Serializer): - resourceModuleName = serializers.CharField(help_text="Name of Resource as defined in the Service Model", - required=True) - serviceResourceId = serializers.CharField(help_text="Resource Id defined in the Service Model", required=True) + resourceModuleName = serializers.CharField( + help_text="Name of Resource as defined in the Service Model", + required=True) + serviceResourceId = serializers.CharField( + help_text="Resource Id defined in the Service Model", + required=True) entitlementPoolUUID = serializers.ListField( help_text="A list of entitlementPoolUUIDs", - child=serializers.CharField(help_text="entitlementPoolUUID", required=True), - required=True - ) + child=serializers.CharField( + help_text="entitlementPoolUUID", + required=True), + required=True) licenseKeyGroupUUID = serializers.ListField( help_text="A list of licenseKeyGroupUUID", - child=serializers.CharField(help_text="licenseKeyGroupUUID", required=True), - required=True - ) + child=serializers.CharField( + help_text="licenseKeyGroupUUID", + required=True), + required=True) entitlementPoolInvariantUUID = serializers.ListField( help_text="A list of entitlementPoolInvariantUUIDs", - child=serializers.CharField(help_text="entitlementPoolInvariantUUID", required=True), - required=True - ) + child=serializers.CharField( + help_text="entitlementPoolInvariantUUID", + required=True), + required=True) licenseKeyGroupInvariantUUID = serializers.ListField( help_text="A list of licenseKeyGroupInvariantUUID", - child=serializers.CharField(help_text="licenseKeyGroupInvariantUUID", required=True), - required=True - ) + child=serializers.CharField( + help_text="licenseKeyGroupInvariantUUID", + required=True), + required=True) class AssignmentInfoSerializer(serializers.Serializer): - key = serializers.CharField(help_text="Any attribute Key needed", required=True) - value = serializers.JSONField(help_text="Attribute value for that key", required=True) + key = serializers.CharField( + help_text="Any attribute Key needed", + required=True) + value = serializers.JSONField( + help_text="Attribute value for that key", + required=True) class PlacementSolutionSerializer(serializers.Serializer): - resourceModuleName = serializers.CharField(help_text="Name of Resource as defined in the Service Model", - required=True) - serviceResourceId = serializers.CharField(help_text="Resource Id defined in the Service Model", required=True) - solution = CandidateSerializer(help_text="The Placement Solution", required=True) - assignmentInfo = AssignmentInfoSerializer(help_text="Additonal information related to a candidate", - required=False, many=True) + resourceModuleName = serializers.CharField( + help_text="Name of Resource as defined in the Service Model", + required=True) + serviceResourceId = serializers.CharField( + help_text="Resource Id defined in the Service Model", + required=True) + solution = CandidateSerializer( + help_text="The Placement Solution", + required=True) + assignmentInfo = AssignmentInfoSerializer( + help_text="Additonal information related to a candidate", + required=False, + many=True) class ComprehensiveSolutionSerializer(serializers.ListSerializer): - child = PlacementSolutionSerializer(help_text="A list of placement solutions", - allow_null=True, - required=True) + child = PlacementSolutionSerializer( + help_text="A list of placement solutions", + allow_null=True, + required=True) class SolutionSerializer(serializers.Serializer): - placementSolutions = ComprehensiveSolutionSerializer(help_text="A list of Placement Solutions", - required=True, - allow_empty=True, - many=True) - licenseSolutions = LicenseSolutionSerializer(help_text="A list of License Solutions", - required=False, many=True) + placementSolutions = ComprehensiveSolutionSerializer( + help_text="A list of Placement Solutions", + required=True, + allow_empty=True, + many=True) + licenseSolutions = LicenseSolutionSerializer( + help_text="A list of License Solutions", + required=False, + many=True) class PlaceVnfReqSerializer(serializers.Serializer): - requestId = serializers.CharField(help_text="ID of Homing Request", required=True) - transactionId = serializers.CharField(help_text="ID of Homing Transaction", required=True, allow_null=False, allow_blank=True) - statusMessage = serializers.CharField(help_text="Status Message of Request", required=False, allow_null=True, allow_blank=True) + requestId = serializers.CharField( + help_text="ID of Homing Request", + required=True) + transactionId = serializers.CharField( + help_text="ID of Homing Transaction", + required=True, + allow_null=False, + allow_blank=True) + statusMessage = serializers.CharField( + help_text="Status Message of Request", + required=False, + allow_null=True, + allow_blank=True) requestStatus = serializers.ChoiceField( help_text="The Status of a Request", - choices=["completed", "failed", "pending"], + choices=enum_to_list(PLACE_VNF_REQUEST_STATUS), required=True, - allow_null=False - ) - solutions = SolutionSerializer(help_text="Request Solutions", required=True, allow_null=False) + allow_null=False) + solutions = SolutionSerializer( + help_text="Request Solutions", + required=True, + allow_null=False) diff --git a/lcm/ns_vnfs/tests/tests.py b/lcm/ns_vnfs/tests/tests.py index e2e2f922..6a2ed6bc 100644 --- a/lcm/ns_vnfs/tests/tests.py +++ b/lcm/ns_vnfs/tests/tests.py @@ -31,7 +31,7 @@ from lcm.ns_vnfs.biz.heal_vnfs import NFHealService from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService from lcm.ns_vnfs.biz.subscribe import SubscriptionDeletion from lcm.ns_vnfs.biz.terminate_nfs import TerminateVnfs -from lcm.ns_vnfs.const import VNF_STATUS, INST_TYPE +from lcm.ns_vnfs.enum import VNF_STATUS, INST_TYPE from lcm.ns_vnfs.biz import create_vnfs from lcm.ns_vnfs.biz.place_vnfs import PlaceVnfs from lcm.pub.msapi import resmgr |