From: maopengzhang Date: Wed, 3 Apr 2019 02:07:02 +0000 (+0800) Subject: format NS Instance serializers X-Git-Tag: 1.3.0~57^2~3 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=0552ce7fd9b34966737e4bf824eb79d13ae5ff89;p=vfc%2Fnfvo%2Flcm.git format NS Instance serializers format NS Instance serializers Change-Id: Id02924f234916d3554d701f499691f30d3c69ddb Issue-ID: VFC-1214 Signed-off-by: maopengzhang --- diff --git a/lcm/ns/const.py b/lcm/ns/const.py index c0293598..4eaf8109 100644 --- a/lcm/ns/const.py +++ b/lcm/ns/const.py @@ -101,11 +101,16 @@ CHANGE_RESULTS = enum( PARTIALLY_COMPLETED='PARTIALLY_COMPLETED' ) -IPADDRESSES_TYPES = enum( +IPADDRESSES_TYPE_ENUM = enum( IPV4='IPV4', IPV6='IPV6' ) +IPADDRESSES_TYPE_LIST = [ + IPADDRESSES_TYPE_ENUM.IPV4, + IPADDRESSES_TYPE_ENUM.IPV6 +] + LCCNNOTIFICATION = "NsLcmOperationOccurrenceNotification" NOTIFICATION_TYPES = [ diff --git a/lcm/ns/serializers/sol/cp_serializers.py b/lcm/ns/serializers/sol/cp_serializers.py index c15166d4..bf93d9d9 100644 --- a/lcm/ns/serializers/sol/cp_serializers.py +++ b/lcm/ns/serializers/sol/cp_serializers.py @@ -13,12 +13,9 @@ # limitations under the License. from rest_framework import serializers -from lcm.ns.const import IPADDRESSES_TYPES +from lcm.ns.const import IPADDRESSES_TYPE_LIST + -IPADDRESSES_TYPE = [ - IPADDRESSES_TYPES.IPV4, - IPADDRESSES_TYPES.IPV6 -] LAYER_PROTOCOL = [ "IP_OVER_ETHERNET" ] @@ -37,7 +34,7 @@ class IpAddressesDataSerialzier(serializers.Serializer): type = serializers.ChoiceField( help_text="The type of the IP addresses.", required=True, - choices=IPADDRESSES_TYPE) + choices=IPADDRESSES_TYPE_LIST) fixedAddresses = serializers.ListField( child=serializers.CharField( help_text="Fixed addresses to assign.", @@ -60,7 +57,7 @@ class IpAddressesInfoSerialzier(serializers.Serializer): type = serializers.ChoiceField( help_text="The type of the IP addresses.", required=True, - choices=IPADDRESSES_TYPE) + choices=IPADDRESSES_TYPE_LIST) addresses = serializers.ListField( help_text="An IPV4 or IPV6 address", required=False, diff --git a/lcm/ns/serializers/sol/create_ns_serializers.py b/lcm/ns/serializers/sol/create_ns_serializers.py index d3f7832d..a6b87e2b 100644 --- a/lcm/ns/serializers/sol/create_ns_serializers.py +++ b/lcm/ns/serializers/sol/create_ns_serializers.py @@ -1,4 +1,5 @@ # Copyright (c) 2018, CMCC Technologies Co., Ltd. +# 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. @@ -16,6 +17,15 @@ from rest_framework import serializers class CreateNsRequestSerializer(serializers.Serializer): - nsdId = serializers.CharField(help_text="Identifier of the NSD that defines the NS instance to be created.", required=True, allow_null=False) - nsName = serializers.CharField(help_text="Name of NS", required=True, allow_null=True) - nsDescription = serializers.CharField(help_text="Description of NS", required=True, allow_null=True) + nsdId = serializers.CharField( + help_text="Identifier of the NSD that defines the NS instance to be created.", + required=True, + allow_null=False) + nsName = serializers.CharField( + help_text="Name of NS", + required=True, + allow_null=True) + nsDescription = serializers.CharField( + help_text="Description of NS", + required=True, + allow_null=True) diff --git a/lcm/ns/serializers/sol/ns_instance.py b/lcm/ns/serializers/sol/ns_instance.py index f8e3d824..059ddafe 100644 --- a/lcm/ns/serializers/sol/ns_instance.py +++ b/lcm/ns/serializers/sol/ns_instance.py @@ -21,6 +21,7 @@ from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer from lcm.ns.serializers.sol.ext_virtual_link_info import ExtVirtualLinkInfoSerializer from lcm.ns.serializers.sol.ext_managed_virtual_link_info import ExtManagedVirtualLinkInfo, VnfLinkPortInfo from lcm.ns.serializers.sol.pub_serializers import AffinityOrAntiAffinityRuleSerializer +from lcm.ns.const import IPADDRESSES_TYPE_LIST INSTANTIATION_STATE = [ @@ -30,45 +31,40 @@ INSTANTIATION_STATE = [ class VnfScaleInfoSerializer(serializers.Serializer): - aspectlId = serializers.Serializer(help_text="The scaling aspect", required=True) - scaleLevel = serializers.Serializer(help_text="The scale level for that aspect", required=True) + aspectlId = serializers.Serializer( + help_text="Identifier of the scaling aspect", + required=True) + scaleLevel = serializers.Serializer( + help_text="The scale level for that aspect.", + required=True) class NsScaleInfoSerializer(serializers.Serializer): - nsScalingAspectId = serializers.CharField(help_text="Identifier of the NS scaling aspect.", required=True) - nsScaleLevelId = serializers.CharField(help_text="Identifier of the NS scale level.", required=True) + nsScalingAspectId = serializers.CharField( + help_text="Identifier of the NS scaling aspect.", + required=True) + nsScaleLevelId = serializers.CharField( + help_text="Identifier of the NS scale level.", + required=True) class VnfcCpInfo(serializers.Serializer): id = serializers.CharField( help_text="Identifier of the external CP instance and the related information instance.", - max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=True) cpdId = serializers.CharField( help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.", - max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=True) vnfExtCpId = serializers.CharField( help_text="When the VNFC CP is exposed as external CP of the VNF, the identifier of this external VNF CP.", - required=False, - max_length=255, - allow_null=True, - allow_blank=True) + required=False) cpProtocolInfo = CpProtocolInfoSerializer( help_text="Network protocol information for this CP.", many=True, - required=False, - allow_null=True) + required=False) vnfLinkPortId = serializers.CharField( help_text="Identifier of the vnfLinkPorts structure in the vnfVirtualLinkResourceInfo structure.", - max_length=255, - required=True, - allow_null=False, - allow_blank=False) + required=True) class VnfcResourceInfoSerializer(serializers.Serializer): @@ -87,8 +83,7 @@ class VnfcResourceInfoSerializer(serializers.Serializer): required=True, allow_null=False) storageResourceIds = serializers.ListSerializer( - help_text="References to the VirtualStorage resources. \ - The value refers to a VirtualStorageResourceInfo item in the VnfInstance.", + help_text="References to the VirtualStorage resources. The value refers to a VirtualStorageResourceInfo item in the VnfInstance.", child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True), required=False, allow_null=True) @@ -99,16 +94,13 @@ class VnfcResourceInfoSerializer(serializers.Serializer): allow_null=True, allow_blank=True) vnfcCpInfo = VnfcCpInfo( - help_text="CPs of the VNFC instance. \ - Shall be present when that particular CP of the VNFC instance is associated to an external CP of the VNF instance.", + help_text="CPs of the VNFC instance. Shall be present when that particular CP of the VNFC instance is associated to an external CP of the VNF instance.", many=True, required=False, allow_null=True) metadata = serializers.DictField( help_text="Metadata about this resource.", - child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True), - required=False, - allow_null=True) + required=False) # class VnfLinkPortInfo(serializers.Serializer): @@ -397,23 +389,40 @@ class VnfInstanceSerializer(serializers.Serializer): class PnfExtCpInfoSerializer(serializers.Serializer): - cpInstanceId = serializers.CharField(help_text="Identifier of the CP in the scope of the PNF.", - required=True) + cpInstanceId = serializers.CharField( + help_text="Identifier of the CP in the scope of the PNF.", + required=True) - cpdId = serializers.CharField(help_text="Identifier of (reference to) the Connection Point Descriptor" - "(CPD) for this CP.", required=True) + cpdId = serializers.CharField( + help_text="Identifier of (reference to) the Connection Point Descriptor (CPD) for this CP.", + required=True) - cpProtocolData = CpProtocolDataSerializer(help_text="Parameters for configuring the network protocols on" - "the CP.", required=True, many=True) + cpProtocolData = CpProtocolDataSerializer( + help_text="Parameters for configuring the network protocols on the CP.", + required=True, + many=True) class PnfInfoSerializer(serializers.Serializer): - pnfId = serializers.CharField(help_text="Identifier of the PNF.", required=True) - pnfName = serializers.CharField(help_text="Name of the PNF.", required=True) - pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True) - pnfdInfoId = serializers.CharField(help_text="Identifier of the PNFD information onject related to this PNF.", required=True) - pnfProfileId = serializers.CharField(help_text="Identifier of the related PnfProfile in the NSD on which the PNF is based.", required=True) - cpInfo = PnfExtCpInfoSerializer(help_text="Information on the external CP of the PNF", required=True, many=True) + pnfId = serializers.CharField( + help_text="Identifier of the PNF.", + required=True) + pnfName = serializers.CharField( + help_text="Name of the PNF.", + required=True) + pnfdId = serializers.CharField( + help_text="Identifier of the PNFD on which the PNF is based.", + required=True) + pnfdInfoId = serializers.CharField( + help_text="Identifier of the PNFD information onject related to this PNF.", + required=True) + pnfProfileId = serializers.CharField( + help_text="Identifier of the related PnfProfile in the NSD on which the PNF is based.", + required=True) + cpInfo = PnfExtCpInfoSerializer( + help_text="Information on the external CP of the PNF", + required=True, + many=True) class NsLinkPortInfo(serializers.Serializer): @@ -437,106 +446,181 @@ class NsLinkPortInfo(serializers.Serializer): class NsVirtualLinkInfoSerializer(serializers.Serializer): - id = serializers.CharField(help_text="Identifier of the VL instance.", required=True) - nsVirtualLinkDescId = serializers.CharField(help_text="Identifier of the VLD in the NSD.", required=True) - nsVirtualLinkProfileId = serializers.CharField(help_text="Identifier of the VL profile in the NSD.", required=True) - resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance", required=True, many=True) - linkPort = NsLinkPortInfo(help_text="Link ports of this VL.", many=True, required=False, allow_null=True) + id = serializers.CharField( + help_text="Identifier of the VL instance.", + required=True) + nsVirtualLinkDescId = serializers.CharField( + help_text="Identifier of the VLD in the NSD.", + required=True) + nsVirtualLinkProfileId = serializers.CharField( + help_text="Identifier of the VL profile in the NSD.", + required=True) + resourceHandle = ResourceHandleSerializer( + help_text="Identifier(s) of the virtualised network resource(s) realizing the VL instance", + required=True, + many=True) + linkPort = NsLinkPortInfo( + help_text="Link ports of this VL.", + many=True, + required=False, + allow_null=True) class NsCpHandleSerializer(serializers.Serializer): - vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated to the CP" - "instance.", required=False, allow_null=True) - vnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the VNF external CP instance in the" - "scope of the VNF instance.", - required=False, allow_null=True) - pnfInfoId = serializers.CharField(help_text="Identifier of the PNF instance associated to the CP" - "instance.", required=False, allow_null=True) - pnfExtCpInstanceId = serializers.CharField(help_text="Identifier of the PNF external CP instance in the" - "scope of the PNF.", required=False, allow_null=True) - nsInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated to the SAP" - "instance", required=False, allow_null=True) - nsSapInstanceId = serializers.CharField(help_text="Identifier of the SAP instance in the scope of the NS" - "instance.", required=False, allow_null=True) + vnfInstanceId = serializers.CharField( + help_text="Identifier of the VNF instance associated to the CP instance.", + required=False, + allow_null=True) + vnfExtCpInstanceId = serializers.CharField( + help_text="Identifier of the VNF external CP instance in the scope of the VNF instance.", + required=False, + allow_null=True) + pnfInfoId = serializers.CharField( + help_text="Identifier of the PNF instance associated to the CP instance.", + required=False, + allow_null=True) + pnfExtCpInstanceId = serializers.CharField( + help_text="Identifier of the PNF external CP instance in the scope of the PNF.", + required=False, + allow_null=True) + nsInstanceId = serializers.CharField( + help_text="Identifier of the NS instance associated to the SAP instance", + required=False, + allow_null=True) + nsSapInstanceId = serializers.CharField( + help_text="Identifier of the SAP instance in the scope of the NS instance.", + required=False, + allow_null=True) class MaskSerializer(serializers.Serializer): - startingPoint = serializers.CharField(help_text="Indicates the offset between the last bit of the source" - "mac address and the first bit of the sequence of bits" - "to be matched.", required=True) - length = serializers.CharField(help_text="Indicates the number of bits to be matched", required=True) - value = serializers.CharField(help_text="Provide the sequence of bit values to be matched.", - required=True) + startingPoint = serializers.CharField( + help_text="Indicates the offset between the last bit of the source mac address and the first bit of the sequence of bits to be matched.", + required=True) + length = serializers.CharField( + help_text="Indicates the number of bits to be matched.", + required=True) + value = serializers.CharField( + help_text="Provide the sequence of bit values to be matched.", + required=True) class NfpRuleSerializer(serializers.Serializer): - etherDestinationAddress = serializers.CharField(help_text="Indicates a destination Mac address", - required=False, allow_null=True) - etherSourceAddress = serializers.CharField(help_text="Indicates a source Mac address", - required=False, allow_null=True) - etherType = serializers.ChoiceField(help_text="Indicates the protocol carried over the Ethernet layer", - choices=["IPV4", "IPV6"], required=False, allow_null=True) - vlanTag = serializers.ListField(help_text="ndicates a VLAN identifier in an IEEE 802.1Q-2014 tag", - required=False, allow_null=True) - protocol = serializers.ChoiceField(help_text="Indicates the L4 protocol, For IPv4 [7] this corresponds to" - "the field called Protocol to identifythe next level " - "protocol", choices=["TCP", "UDP", "ICMP"], - required=False, allow_null=True) - dscp = serializers.CharField(help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the" - "6-bit Differentiated Services Code Point (DSCP) field of the" - "IP header.", required=False, allow_null=True) - sourcePortRange = serializers.CharField(help_text="Indicates a range of source ports", - required=False, allow_null=True) - destinationPortRange = serializers.CharField(help_text="Indicates a range of destination ports", - required=False, allow_null=True) - sourceIpAddressPrefix = serializers.CharField(help_text="Indicates the source IP address range in CIDR" - "format.", required=False, allow_null=True) - destinationIpAddressPrefix = serializers.CharField(help_text="Indicates the destination IP address range" - "in CIDRformat.", - required=False, allow_null=True) - extendedCriteria = MaskSerializer(help_text="Indicates values of specific bits in a frame", - required=False, allow_null=True, many=True) + etherDestinationAddress = serializers.CharField( + help_text="Indicates a destination Mac address", + required=False, + allow_null=True) + etherSourceAddress = serializers.CharField( + help_text="Indicates a source Mac address", + required=False, + allow_null=True) + etherType = serializers.ChoiceField( + help_text="Indicates the protocol carried over the Ethernet layer", + choices=IPADDRESSES_TYPE_LIST, + required=False, + allow_null=True) + vlanTag = serializers.ListField( + help_text="ndicates a VLAN identifier in an IEEE 802.1Q-2014 tag", + required=False, + allow_null=True) + protocol = serializers.ChoiceField( + help_text="Indicates the L4 protocol, For IPv4 [7] this corresponds to" + "the field called Protocol to identifythe next level protocol", + choices=["TCP", "UDP", "ICMP"], + required=False, + allow_null=True) + dscp = serializers.CharField( + help_text="For IPv4 [7] a string of 0 and 1 digits that corresponds to the" + "6-bit Differentiated Services Code Point (DSCP) field of the IP header.", + required=False, + allow_null=True) + sourcePortRange = serializers.CharField( + help_text="Indicates a range of source ports", + required=False, + allow_null=True) + destinationPortRange = serializers.CharField( + help_text="Indicates a range of destination ports", + required=False, + allow_null=True) + sourceIpAddressPrefix = serializers.CharField( + help_text="Indicates the source IP address range in CIDR format.", + required=False, + allow_null=True) + destinationIpAddressPrefix = serializers.CharField( + help_text="Indicates the destination IP address range in CIDR format.", + required=False, + allow_null=True) + extendedCriteria = MaskSerializer( + help_text="Indicates values of specific bits in a frame", + required=False, + allow_null=True, + many=True) class NfpInfoSerializer(serializers.Serializer): - id = serializers.CharField(help_text="Identifier of this NFP instance.", required=True) - nfpdId = serializers.CharField(help_text="Identifier of the NFPD used to instantiate this NFP" - "instance.", required=False, allow_null=True) - nfpName = serializers.CharField(help_text="Human readable name for the NFP instance.", - required=False, allow_null=True) - description = serializers.CharField(help_text="Human readable description for the NFP instance.", - required=True) - nscpHandle = NsCpHandleSerializer(help_text="Identifier(s) of the CPs and/or SAPs which the NFP " - "passes by", required=True, many=True) - totalCp = serializers.CharField(help_text="Total number of CP and SAP instances in this NFP" - "instance.", required=False, allow_null=True) - nfpRule = NfpRuleSerializer(help_text="The NfpRule data type is an expression of the conditions that " - "shall be met in order for the NFP to be applicable to the packet", - required=True) - nfpState = serializers.ChoiceField(help_text="The state of the NFP instance.", - choices=["ENABLED", "DISABLED"], required=True) + id = serializers.CharField( + help_text="Identifier of this NFP instance.", + required=True) + nfpdId = serializers.CharField( + help_text="Identifier of the NFPD used to instantiate this NFP instance.", + required=False, + allow_null=True) + nfpName = serializers.CharField( + help_text="Human readable name for the NFP instance.", + required=False, + allow_null=True) + description = serializers.CharField( + help_text="Human readable description for the NFP instance.", + required=True) + nscpHandle = NsCpHandleSerializer( + help_text="Identifier(s) of the CPs and/or SAPs which the NFP passes by", + required=True, + many=True) + totalCp = serializers.CharField( + help_text="Total number of CP and SAP instances in this NFP instance.", + required=False, + allow_null=True) + nfpRule = NfpRuleSerializer( + help_text="The NfpRule data type is an expression of the conditions that shall be met in order for the NFP to be applicable to the packet", + required=True) + nfpState = serializers.ChoiceField( + help_text="The state of the NFP instance.", + choices=["ENABLED", "DISABLED"], + required=True) class VnffgInfoSerializer(serializers.Serializer): - id = serializers.CharField(help_text="Identifier of this VNFFG instance.", required=True) - vnffgdId = serializers.CharField(help_text="Identifier of the VNFFGD in the NSD.", required=True) - vnfInstanceId = serializers.ListField(help_text="Identifier(s) of the constituent VNF instance(s) of this" - "VNFFG instance.", - child=serializers.CharField(help_text="ID of vnf instance"), - required=True) - pnfInfoId = serializers.ListField(help_text="Identifier(s) of the constituent PNF instance(s) of this" - "VNFFG instance", - child=serializers.CharField(help_text="ID of pnf info"), - required=False, allow_null=True) - nsVirtualLinkInfoId = serializers.ListField(help_text="Identifier(s) of the constituent VL instance(s) of" - "thisVNFFG instance.", - child=serializers.CharField( - help_text="ID of ns virtual link info"), required=True) - nsCpHandle = NsCpHandleSerializer(help_text="Identifiers of the CP instances attached to the " - "constituent VNFs and PNFs or the SAP instances of " - "the VNFFG.", required=True, allow_null=False, many=True) - nfpInfo = NfpInfoSerializer(help_text="Information on the NFP instances.", - required=True, allow_null=False, many=True) + id = serializers.CharField( + help_text="Identifier of this VNFFG instance.", + required=True) + vnffgdId = serializers.CharField( + help_text="Identifier of the VNFFGD in the NSD.", + required=True) + vnfInstanceId = serializers.ListField( + help_text="Identifier(s) of the constituent VNF instance(s) of this VNFFG instance.", + child=serializers.CharField( + help_text="ID of vnf instance"), + required=True) + pnfInfoId = serializers.ListField( + help_text="Identifier(s) of the constituent PNF instance(s) of this VNFFG instance", + child=serializers.CharField(help_text="ID of pnf info"), + required=False, + allow_null=True) + nsVirtualLinkInfoId = serializers.ListField( + help_text="Identifier(s) of the constituent VL instance(s) of thisVNFFG instance.", + child=serializers.CharField(help_text="ID of ns virtual link info"), + required=True) + nsCpHandle = NsCpHandleSerializer( + help_text="Identifiers of the CP instances attached to the " + "constituent VNFs and PNFs or the SAP instances of the VNFFG.", + required=True, + allow_null=False, + many=True) + nfpInfo = NfpInfoSerializer( + help_text="Information on the NFP instances.", + required=True, + allow_null=False, + many=True) class SapInfo(serializers.Serializer): @@ -645,8 +729,10 @@ class NsInstanceSerializer(serializers.Serializer): allow_null=True, many=True) additionalAffinityOrAntiAffinityRule = AffinityOrAntiAffinityRuleSerializer( + help_text="Specifies additional affinity or anti-affinity constraint for the VNF instances to be instantiated as part of the NS instantiation.", many=True, required=False, - allow_null=True, - help_text="Specifies additional affinity or anti-affinity constraint for the VNF instances to be instantiated as part of the NS instantiation.") - _links = NsLinkSerializer(help_text="The links of the NS instance.", required=True) + allow_null=True) + _links = NsLinkSerializer( + help_text="The links of the NS instance.", + required=True)