aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/ns/serializers/create_ns_serializers.py45
-rw-r--r--lcm/ns/serializers/inst_ns_serializers.py89
-rw-r--r--lcm/ns/serializers/ns_serializers.py17
-rw-r--r--lcm/ns/serializers/pub_serializers.py68
-rw-r--r--lcm/ns/serializers/update_serializers.py18
-rw-r--r--lcm/ns/tests/test_ns_instant.py11
-rw-r--r--lcm/ns/views/inst_ns_view.py2
7 files changed, 121 insertions, 129 deletions
diff --git a/lcm/ns/serializers/create_ns_serializers.py b/lcm/ns/serializers/create_ns_serializers.py
index 3128f1d1..d52c1cfd 100644
--- a/lcm/ns/serializers/create_ns_serializers.py
+++ b/lcm/ns/serializers/create_ns_serializers.py
@@ -14,8 +14,7 @@
from rest_framework import serializers
-from lcm.ns.serializers.ns_serializers import IpAddress
-from lcm.ns.serializers.common_Link import LinkSerializer
+from lcm.ns.serializers.pub_serializers import Links, IpAddressSerialzier, ipAddressesSerializer
class ContextSerializer(serializers.Serializer):
@@ -40,10 +39,8 @@ class VnfInstanceSerializer(serializers.Serializer):
class IpOverEthernetAddressDataSerializer(serializers.Serializer):
macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
- ipAddresses = serializers.ListField(help_text="List of IP addresses to assign to the extCP instance.",
- child=IpAddress(
- help_text="List of IP addresses to assign to the extCP instance.",
- required=True), required=False, allow_null=True, )
+ ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+ required=False, allow_null=True, many=True)
class cpProtocolDataSerializer(serializers.Serializer):
@@ -196,30 +193,6 @@ class VnffgInfoSerializer(serializers.Serializer):
required=True, allow_null=False, many=True)
-class AddressRange(serializers.Serializer):
- minAddress = serializers.IPAddressField(help_text="Lowest IP address belonging to the range.",
- required=True)
- maxAddress = serializers.IPAddressField(help_text="Highest IP address belonging to the range.",
- required=True)
-
-
-class ipAddressesSerializer(serializers.Serializer):
- type = serializers.ChoiceField(help_text="The type of the IP addresses.",
- choices=["IPV4", "IPV6"], required=True)
- addresses = serializers.ListField(help_text="Fixed addresses assigned (from the subnet defined by "
- "subnetId if provided)",
- child=serializers.CharField(help_text="An IPV4 or IPV6 address."),
- required=False, allow_null=True)
-# question
- isDynamic = serializers.BooleanField(help_text="Indicates whether this set of addresses was assigned "
- "dynamically (true) or based on address information "
- "provided as input from the API consumer (false).",
- required=False, default=True)
- addressRange = AddressRange(help_text="An IP address range used", required=False, allow_null=True)
- subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet"
- "resource in the VIM", required=False, allow_null=True)
-
-
class IpOverEthernetAddressInfoSerializer(serializers.Serializer):
macAddress = serializers.CharField(help_text="Assigned MAC address", required=True)
ipAddresses = ipAddressesSerializer(help_text="Addresses assigned to the CP or SAP instance.",
@@ -269,18 +242,6 @@ class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"], required=True)
-class Links(serializers.Serializer):
- self = LinkSerializer(help_text="URI of this resource.", required=True)
- nestedNsInstances = LinkSerializer(help_text="Links to the nested NS instances of the present NS"
- "instance.", required=False, allow_null=True)
- instantiate = LinkSerializer(help_text="Link to the 'instantiate' task resource", required=False,
- allow_null=True)
- terminate = LinkSerializer(help_text="Link to the 'terminate' task resource", required=False, allow_null=True)
- update = LinkSerializer(help_text="Link to the 'update' task resource", required=False, allow_null=True)
- scale = LinkSerializer(help_text="Link to the 'scale' task resource", required=False, allow_null=True)
- heal = LinkSerializer(help_text="Link to the 'heal' task resource", required=False, allow_null=True)
-
-
class CreateNsRespSerializer(serializers.Serializer):
nsInstanceId = serializers.CharField(help_text="ID of NS instance", required=True)
nsInstanceName = serializers.CharField(help_text="Human readable name of the NS instance.", required=True)
diff --git a/lcm/ns/serializers/inst_ns_serializers.py b/lcm/ns/serializers/inst_ns_serializers.py
index 8413a074..cd01d772 100644
--- a/lcm/ns/serializers/inst_ns_serializers.py
+++ b/lcm/ns/serializers/inst_ns_serializers.py
@@ -14,7 +14,7 @@
from rest_framework import serializers
-from lcm.ns.serializers.create_ns_serializers import IpOverEthernetAddressDataSerializer
+from lcm.ns.serializers.pub_serializers import IpOverEthernetAddressDataSerializer
from lcm.ns.serializers.update_serializers import AddPnfDataSerializer, VnfInstanceDataSerializer
@@ -30,28 +30,23 @@ class SapDataSerializer(serializers.Serializer):
sapdId = serializers.CharField(help_text="Reference to the SAPD for this SAP.", required=True)
sapName = serializers.CharField(help_text="Human readable name for the SAP.", required=True)
description = serializers.CharField(help_text="Human readable description for the SAP.", required=True)
- sapProtocolData = serializers.ListField(help_text="Parameters for configuring the network protocols on"
- "the SAP.",
- child=(CpProtocolDataSerializer(help_text="This type represents "
- "network protocol "
- "data.")),
- required=False, allow_null=True)
+ sapProtocolData = CpProtocolDataSerializer(help_text="Parameters for configuring the network protocols"
+ " on the SAP.",
+ required=False, allow_null=True, many=True)
class civicAddressElementSerializer(serializers.Serializer):
caType = serializers.CharField(help_text="Describe the content type of caValue.", required=True)
- caValue = serializers.Serializer(help_text="Content of civic address element corresponding to the"
- "caType.", required=True)
+ caValue = serializers.CharField(help_text="Content of civic address element corresponding to the"
+ "aType.", required=True)
class LocationConstraintsSerializer(serializers.Serializer):
countryCode = serializers.CharField(help_text="The two-letter ISO 3166 [29] country code in capital"
"letters.", required=True)
- civicAddressElement = serializers.ListField(help_text="Zero or more elements comprising the civic"
- "address.",
- child=civicAddressElementSerializer(
- help_text="caType and caValue", required=True),
- required=False, allow_null=True)
+ civicAddressElement = civicAddressElementSerializer(help_text="Zero or more elements comprising the civic"
+ "address.",
+ required=False, allow_null=True, many=True)
class VnfLocationConstraintSerializer(serializers.Serializer):
@@ -89,65 +84,35 @@ class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
class InstantNsReqSerializer(serializers.Serializer):
nsFlavourId = serializers.CharField(help_text="Identifier of the NS deployment flavour to be"
"instantiated.", required=True)
- sapData = serializers.ListField(help_text="Create data concerning the SAPs of this NS",
- child=(SapDataSerializer(
- help_text="This type represents the information related to a SAP"
- "of a NS.", required=True)),
- required=False, allow_null=True)
- addpnfData = serializers.ListField(help_text="Information on the PNF(s) that are part of this NS.",
- child=(AddPnfDataSerializer(help_text="This type specifies an PNF to "
- "be added to the NS instance and"
- "the PNF Profile to use for"
- "this PNF.", required=True)),
- required=False, allow_null=True)
- vnfInstanceData = serializers.ListField(help_text="Specify an existing VNF instance to be used in the"
- "NS.",
- child=(VnfInstanceDataSerializer(help_text="This type specifies "
- "an existing VNF "
- "instance to be used "
- "in the NS instance "
- "and if needed",
- required=True)),
- required=False, allow_null=True)
+ sapData = SapDataSerializer(help_text="Create data concerning the SAPs of this NS",
+ required=False, allow_null=True, many=True)
+ addpnfData = AddPnfDataSerializer(help_text="Information on the PNF(s) that are part of this NS.",
+ required=False, allow_null=True, many=True)
+ vnfInstanceData = VnfInstanceDataSerializer(help_text="Specify an existing VNF instance to be used in "
+ "the NS.",
+ required=False, allow_null=True, many=True)
nestedNsInstanceId = serializers.ListField(help_text="Specify an existing NS instance to be used as a "
"nested NS within the NS",
required=False, allow_null=True)
- localizationLanguage = serializers.ListField(help_text="Defines the location constraints for the VNF to"
- "be instantiated as part of the NS instantiation.",
- child=(VnfLocationConstraintSerializer(
- help_text="This type represents the association of"
- "location constraints to a VNF instance to be"
- "created according to a specific VNF profile",
- required=True)), required=False, allow_null=True)
+ localizationLanguage = VnfLocationConstraintSerializer(help_text="Defines the location constraints for "
+ "the VNF to be instantiated as part of"
+ " the NS instantiation.",
+ required=False, allow_null=True, many=True)
additionalParamForNs = serializers.DictField(
help_text="Allows the OSS/BSS to provide additional parameters at the NS level ",
child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
required=False,
allow_null=True
)
- additionalParamsForVnf = serializers.ListField(help_text="Allows the OSS/BSS to provide additional"
- "parameter(s)per VNF instance",
- child=(ParamsForVnfSerializer(
- help_text="This type defines the additional parameters"
- "for the VNF instance to be created"
- "associated with an NS instance",
- required=True)), required=False, allow_null=True)
+ additionalParamsForVnf = ParamsForVnfSerializer(help_text="Allows the OSS/BSS to provide additional "
+ "parameter(s)per VNF instance",
+ required=False, allow_null=True, many=True)
startTime = serializers.DateTimeField(help_text="Timestamp indicating the earliest time to instantiate"
"the NS.", required=False, allow_null=True)
nsInstantiationLevelId = serializers.CharField(help_text="Identifies one of the NS instantiation levels"
"declared in the DF applicable to this NS "
"instance", required=False, allow_null=True)
- additionalAffinityOrAntiAffiniityRule = serializers.ListField(help_text="Specifies additional affinity or"
- "anti-affinity constraint for the"
- "VNF instances to be instantiated"
- "as part of the NS "
- "instantiation.",
- child=(
- AffinityOrAntiAffinityRuleSerializer(
- help_text="This type describes the"
- "additional affinity or"
- "anti-affinity rule"
- "applicable between the"
- "VNF instances",
- required=True)),
- required=False, allow_null=True)
+ additionalAffinityOrAntiAffiniityRule = AffinityOrAntiAffinityRuleSerializer(
+ help_text="Specifies additional affinity or anti-affinity constraint for the VNF instances to be"
+ " instantiated as part of the NS instantiation.",
+ required=False, allow_null=True, many=True)
diff --git a/lcm/ns/serializers/ns_serializers.py b/lcm/ns/serializers/ns_serializers.py
index 322facb4..f525674d 100644
--- a/lcm/ns/serializers/ns_serializers.py
+++ b/lcm/ns/serializers/ns_serializers.py
@@ -14,6 +14,7 @@
from rest_framework import serializers
from lcm.ns_pnfs.serializers.pnf_serializer import PnfInstanceSerializer
+from lcm.ns.serializers.pub_serializers import IpOverEthernetAddressDataSerializer
class VnfInstSerializer(serializers.Serializer):
@@ -70,17 +71,9 @@ class AddressRange(serializers.Serializer):
maxAddress = serializers.IPAddressField(help_text="Highest IP address belonging to the range.", required=True)
-class IpAddress(serializers.Serializer):
- type = serializers.ChoiceField(help_text="The type of the IP addresses.", required=True, choices=["IPV4", "IPV6"])
- fixedAddresses = serializers.ListField(child=serializers.CharField(help_text="Fixed addresses to assign."), required=False)
- numDynamicAddresses = serializers.IntegerField(help_text="Number of dynamic addresses to assign.", required=False)
- addressRange = AddressRange(help_text="An IP address range to be used.", required=False)
- subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet resource in the VIM.", required=False, allow_null=True, allow_blank=True)
-
-
-class IpOverEthernetSerializer(serializers.Serializer):
- macAddress = serializers.CharField(help_text="MAC address.", required=False, allow_null=True, allow_blank=True)
- ipAddresses = IpAddress(help_text="List of IP addresses to assign to the extCP instance.", required=False, many=True)
+# class IpOverEthernetSerializer(serializers.Serializer):
+# macAddress = serializers.CharField(help_text="MAC address.", required=False, allow_null=True, allow_blank=True)
+# ipAddresses = IpAddress(help_text="List of IP addresses to assign to the extCP instance.", required=False, many=True)
class CpProtocolInfoSerializer(serializers.Serializer):
@@ -89,7 +82,7 @@ class CpProtocolInfoSerializer(serializers.Serializer):
choices=["IP_OVER_ETHERNET"],
required=True,
allow_null=False)
- ipOverEthernet = IpOverEthernetSerializer(
+ ipOverEthernet = IpOverEthernetAddressDataSerializer(
help_text="IP addresses over Ethernet to assign to the extCP instance.",
required=False,
allow_null=True)
diff --git a/lcm/ns/serializers/pub_serializers.py b/lcm/ns/serializers/pub_serializers.py
new file mode 100644
index 00000000..533aa1c7
--- /dev/null
+++ b/lcm/ns/serializers/pub_serializers.py
@@ -0,0 +1,68 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+
+# 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 rest_framework import serializers
+from lcm.ns.serializers.common_Link import LinkSerializer
+
+
+class AddressRangeSerializer(serializers.Serializer):
+ minAddress = serializers.IPAddressField(help_text="Lowest IP address belonging to the range.",
+ required=True)
+ maxAddress = serializers.IPAddressField(help_text="Highest IP address belonging to the range.",
+ required=True)
+
+
+class IpAddressSerialzier(serializers.Serializer):
+ type = serializers.ChoiceField(help_text="The type of the IP addresses.",
+ required=True, choices=["IPV4", "IPV6"])
+ fixedAddresses = serializers.ListField(child=serializers.CharField(help_text="Fixed addresses to assign.",
+ required=False, allow_null=True))
+ numDynamicAddresses = serializers.IntegerField(help_text="Number of dynamic addresses to assign.",
+ required=False)
+ addressRange = AddressRangeSerializer(help_text="An IP address range to be used.", required=False)
+ subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet resource"
+ " in the VIM.", required=False, allow_null=True,
+ allow_blank=True)
+
+
+class ipAddressesSerializer(serializers.Serializer):
+ type = serializers.ChoiceField(help_text="The type of the IP addresses.",
+ required=True, choices=["IPV4", "IPV6"])
+ addresses = serializers.ListField(help_text="An IPV4 or IPV6 address", required=False, allow_null=True)
+ isDynamic = serializers.BooleanField(help_text="Indicates whether this set of addresses was assigned"
+ " dynamically (true) or based on address information"
+ " provided as input from the API consumer (false). ",
+ required=False)
+ addressRange = AddressRangeSerializer(help_text="An IP address range used,",
+ required=False, allow_null=True)
+ subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet resource in "
+ "the VIM. ", required=False, allow_null=True)
+
+
+class Links(serializers.Serializer):
+ self = LinkSerializer(help_text="URI of this resource.", required=True)
+ nestedNsInstances = LinkSerializer(help_text="Links to the nested NS instances of the present NS"
+ "instance.", required=False, allow_null=True)
+ instantiate = LinkSerializer(help_text="Link to the 'instantiate' task resource", required=False,
+ allow_null=True)
+ terminate = LinkSerializer(help_text="Link to the 'terminate' task resource", required=False, allow_null=True)
+ update = LinkSerializer(help_text="Link to the 'update' task resource", required=False, allow_null=True)
+ scale = LinkSerializer(help_text="Link to the 'scale' task resource", required=False, allow_null=True)
+ heal = LinkSerializer(help_text="Link to the 'heal' task resource", required=False, allow_null=True)
+
+
+class IpOverEthernetAddressDataSerializer(serializers.Serializer):
+ macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
+ ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+ required=False, allow_null=True, many=True)
diff --git a/lcm/ns/serializers/update_serializers.py b/lcm/ns/serializers/update_serializers.py
index 06217d80..020ded06 100644
--- a/lcm/ns/serializers/update_serializers.py
+++ b/lcm/ns/serializers/update_serializers.py
@@ -12,7 +12,8 @@
# limitations under the License.
from rest_framework import serializers
-from lcm.ns.serializers.ns_serializers import IpAddress
+
+from lcm.ns.serializers.pub_serializers import IpAddressSerialzier
class VnfInstanceDataSerializer(serializers.Serializer):
@@ -36,7 +37,8 @@ class InstantiateVnfDataSerializer(serializers.Serializer):
class IpOverEthernetAddressDataSerializer(serializers.Serializer):
macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
- ipAddresses = serializers.ListField(help_text="List of IP addresses to assign to the extCP instance.", child=IpAddress(help_text="IP addresses to assign to the extCP instance.", required=False), required=False, allow_null=True)
+ ipAddresses = IpAddressSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+ required=False, allow_null=True, many=True)
class CpProtocolDataSerializer(serializers.Serializer):
@@ -304,10 +306,8 @@ class PnfExtCpDataSerializer(serializers.Serializer):
required=False, allow_null=True)
cpdId = IdentifierInNsdSerializer(help_text="Identifier of the Connection Point Descriptor (CPD) for this CP",
required=False, allow_null=True)
- cpProtocolData = serializers.ListField(help_text="Address assigned for this CP.",
- child=(CpProtocolDataSerializer(
- help_text="This type represents network protocol data.", required=True)),
- required=False, allow_null=True)
+ cpProtocolData = CpProtocolDataSerializer(help_text="Address assigned for this CP.",
+ required=False, allow_null=True, many=True)
class AddPnfDataSerializer(serializers.Serializer):
@@ -316,10 +316,8 @@ class AddPnfDataSerializer(serializers.Serializer):
pnfdId = serializers.CharField(help_text="Identifier of the PNFD on which the PNF is based.", required=True)
pnfProfileId = serializers.CharField(
help_text="Identifier of related PnfProfile in the NSD on which the PNF is based.", required=True)
- cpData = serializers.ListField(help_text="Address assigned for the PNF external CP(s). ",
- child=(PnfExtCpDataSerializer(
- help_text="Serializer data of pnf ext cp", required=True)),
- required=False, allow_null=True)
+ cpData = PnfExtCpDataSerializer(help_text="Address assigned for the PNF external CP(s). ",
+ required=False, allow_null=True, many=True)
class ModifyPnfDataSerializer(serializers.Serializer):
diff --git a/lcm/ns/tests/test_ns_instant.py b/lcm/ns/tests/test_ns_instant.py
index 38c28751..df4f4034 100644
--- a/lcm/ns/tests/test_ns_instant.py
+++ b/lcm/ns/tests/test_ns_instant.py
@@ -54,10 +54,17 @@ class TestNsInstant(TestCase):
"additionalParamForNs": {
"sdnControllerId": "2"
},
- "locationConstraints": [{
+ "nsFlavourId": 12345,
+ "localizationLanguage": [{
"vnfProfileId": "vnfd1",
"locationConstraints": {
- "vimId": "3"
+ "countryCode": "countryCode",
+ # "vimId": "3",
+ "civicAddressElement": [
+ {"caType": "type1",
+ "caValue": 1
+ }
+ ]
}
}]
}
diff --git a/lcm/ns/views/inst_ns_view.py b/lcm/ns/views/inst_ns_view.py
index 795384c8..ce704d33 100644
--- a/lcm/ns/views/inst_ns_view.py
+++ b/lcm/ns/views/inst_ns_view.py
@@ -19,7 +19,7 @@ from rest_framework.views import APIView
from drf_yasg.utils import swagger_auto_schema
from lcm.ns.biz.ns_instant import InstantNSService
-from lcm.ns.serializers.ns_serializers import InstantNsReqSerializer
+from lcm.ns.serializers.inst_ns_serializers import InstantNsReqSerializer
from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
logger = logging.getLogger(__name__)