fix the test and serializer 97/75797/1
authortianxing <15210838572@139.com>
Tue, 15 Jan 2019 04:22:35 +0000 (12:22 +0800)
committertianxing <15210838572@139.com>
Tue, 15 Jan 2019 04:22:46 +0000 (12:22 +0800)
Change-Id: Ieae002091c713d3a54900e3b4aa11223f5486a93
Signed-off-by: tianxing <15210838572@139.com>
Issue-ID: VFC-1248

17 files changed:
lcm/ns/serializers/create_ns_serializers.py
lcm/ns/serializers/inst_ns_serializers.py
lcm/ns/serializers/ns_serializers.py [deleted file]
lcm/ns/serializers/pub_serializers.py
lcm/ns/serializers/scale_ns_serializers.py
lcm/ns/serializers/terminate_ns_serializer.py [new file with mode: 0644]
lcm/ns/serializers/update_serializers.py
lcm/ns/tests/test_ns_heal.py
lcm/ns/tests/test_ns_instant.py
lcm/ns/views/create_ns_view.py
lcm/ns/views/get_del_ns_view.py
lcm/ns/views/heal_ns_view.py
lcm/ns/views/inst_ns_post_deal_view.py
lcm/ns/views/inst_ns_view.py
lcm/ns/views/scale_ns_views.py
lcm/ns/views/term_ns_view.py
lcm/ns/views/update_ns_view.py

index d52c1cf..347e7cf 100644 (file)
@@ -45,10 +45,10 @@ class IpOverEthernetAddressDataSerializer(serializers.Serializer):
 
 class cpProtocolDataSerializer(serializers.Serializer):
     layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s).",
-                                            choices=["IP_OVER_ETHERNET"], required=True)
+                                            choices=["IP_OVER_ETHERNET"], required=True, allow_null=False)
     ipOverEthernet = IpOverEthernetAddressDataSerializer(help_text="Network address data for IP over Ethernet"
                                                                    " to assign to the extCP instance.",
-                                                         required=True, many=True)
+                                                         required=False, allow_null=True)
 
 
 class PnfExtCpInfoSerializer(serializers.Serializer):
index cd01d77..54eb3b9 100644 (file)
@@ -116,3 +116,7 @@ class InstantNsReqSerializer(serializers.Serializer):
         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)
+
+
+class InstNsPostDealReqSerializer(serializers.Serializer):
+    status = serializers.CharField(help_text="Status of NS Inst", required=True)
diff --git a/lcm/ns/serializers/ns_serializers.py b/lcm/ns/serializers/ns_serializers.py
deleted file mode 100644 (file)
index f525674..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-# Copyright 2018 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 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):
-    vnfInstanceId = serializers.CharField(help_text="ID of VNF instance", required=True)
-    vnfInstanceName = serializers.CharField(help_text="Name of VNF instance", required=False, allow_null=True, allow_blank=True)
-    vnfdId = serializers.CharField(help_text="ID of VNFD", required=False, allow_null=True, allow_blank=True)
-
-
-class CpInstInfoSerializer(serializers.Serializer):
-    cpInstanceId = serializers.CharField(help_text="ID of CP instance", required=True)
-    cpInstanceName = serializers.CharField(help_text="Name of CP instance", required=False, allow_null=True, allow_blank=True)
-    cpdId = serializers.CharField(help_text="ID of CPD", required=False, allow_null=True, allow_blank=True)
-
-
-class VlInstSerializer(serializers.Serializer):
-    vlInstanceId = serializers.CharField(help_text="ID of VL instance", required=True)
-    vlInstanceName = serializers.CharField(help_text="Name of VL instance", required=False, allow_null=True, allow_blank=True)
-    vldId = serializers.CharField(help_text="ID of VLD", required=False, allow_null=True, allow_blank=True)
-    relatedCpInstanceId = CpInstInfoSerializer(help_text="Related CP instances", many=True)
-
-
-class VnffgInstSerializer(serializers.Serializer):
-    vnffgInstanceId = serializers.CharField(help_text="ID of VNFFG instance", required=True)
-    vnfdId = serializers.CharField(help_text="ID of VNFD", required=False, allow_null=True, allow_blank=True)
-    pnfId = serializers.CharField(help_text="ID of PNF", required=False, allow_null=True, allow_blank=True)
-    virtualLinkId = serializers.CharField(help_text="ID of virtual link", required=False, allow_null=True, allow_blank=True)
-    cpdId = serializers.CharField(help_text="ID of CPD", required=False, allow_null=True, allow_blank=True)
-    nfp = serializers.CharField(help_text="nfp", required=False, allow_null=True, allow_blank=True)
-
-
-class QueryNsRespSerializer(serializers.Serializer):
-    nsInstanceId = serializers.CharField(help_text="ID of NS instance", required=True)
-    nsName = serializers.CharField(help_text="Name of NS instance", required=False, allow_null=True, allow_blank=True)
-    description = serializers.CharField(help_text="Description of NS instance", required=False, allow_null=True, allow_blank=True)
-    nsdId = serializers.CharField(help_text="ID of NSD", required=True)
-    vnfInfo = VnfInstSerializer(help_text="VNF instances", many=True, required=False, allow_null=True)
-    pnfInfo = PnfInstanceSerializer(help_text="PNF instances", many=True, required=False, allow_null=True)
-    vlInfo = VlInstSerializer(help_text="VL instances", many=True, required=False, allow_null=True)
-    vnffgInfo = VnffgInstSerializer(help_text="VNFFG instances", many=True, required=False, allow_null=True)
-    nsState = serializers.CharField(help_text="State of NS instance", required=False, allow_null=True, allow_blank=True)
-
-
-class VnfLocationSerializer(serializers.Serializer):
-    vimId = serializers.CharField(help_text="ID of VIM", required=False, allow_null=True, allow_blank=True)
-
-
-class LocationConstraintSerializer(serializers.Serializer):
-    vnfProfileId = serializers.CharField(help_text="ID of VNF profile", required=False, allow_null=True, allow_blank=True)
-    locationConstraints = VnfLocationSerializer(help_text="Location constraint", required=False, allow_null=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 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):
-    layerProtocol = serializers.ChoiceField(
-        help_text="The identifier of layer(s) and protocol(s) associated to the network address information.",
-        choices=["IP_OVER_ETHERNET"],
-        required=True,
-        allow_null=False)
-    ipOverEthernet = IpOverEthernetAddressDataSerializer(
-        help_text="IP addresses over Ethernet to assign to the extCP instance.",
-        required=False,
-        allow_null=True)
-
-
-class PnfExtCpData(serializers.Serializer):
-    cpInstanceId = serializers.CharField(help_text="Identifier of the CP", required=False, allow_null=True, allow_blank=True)
-    cpdId = serializers.CharField(help_text="Identifier of the Connection Point Descriptor", required=False, allow_null=True, allow_blank=True)
-    cpProtocolData = CpProtocolInfoSerializer(help_text="Address assigned for this CP", required=True, allow_null=False, many=True)
-
-
-class AddPnfData(serializers.Serializer):
-    pnfId = serializers.CharField(help_text="Identifier of the PNF", required=True, allow_null=False, allow_blank=True)
-    pnfName = serializers.CharField(help_text="Name of the PNF", required=True, allow_null=True, allow_blank=True)
-    pnfdId = serializers.CharField(help_text="Identifier of the PNFD", required=True, allow_null=False, allow_blank=True)
-    pnfProfileId = serializers.CharField(help_text="Identifier of related PnfProfile in the NSD", required=True, allow_null=False, allow_blank=True)
-    cpData = PnfExtCpData(help_text="Address assigned for the PNF external CP", required=False, many=True)
-
-
-class InstantNsReqSerializer(serializers.Serializer):
-    locationConstraints = LocationConstraintSerializer(help_text="Location constraints", required=False, many=True)
-    additionalParamForNs = serializers.DictField(
-        help_text="Additional param for NS",
-        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
-        required=False,
-        allow_null=True
-    )
-    addpnfData = AddPnfData(help_text="Information on the PNF", required=False, many=True)
-
-
-class NsOperateJobSerializer(serializers.Serializer):
-    jobId = serializers.CharField(help_text="ID of NS operate job", required=True)
-
-
-class TerminateNsReqSerializer(serializers.Serializer):
-    terminationType = serializers.CharField(help_text="Type of NS termination", required=False, allow_null=True, allow_blank=True)
-    gracefulTerminationTimeout = serializers.CharField(help_text="Timeout of NS graceful termination", required=False, allow_null=True, allow_blank=True)
-
-
-class InstNsPostDealReqSerializer(serializers.Serializer):
-    status = serializers.CharField(help_text="Status of NS Inst", required=True)
-
-
-class ScaleNsByStepsSerializer(serializers.Serializer):
-    aspectId = serializers.CharField(help_text="ID of aspect", required=True)
-    numberOfSteps = serializers.CharField(help_text="Number of steps", required=True)
-    scalingDirection = serializers.CharField(help_text="Scaling direction", required=True)
-
-
-class ScaleNsDataSerializer(serializers.Serializer):
-    scaleNsByStepsData = ScaleNsByStepsSerializer(help_text="Scale NS by steps data", many=True)
-
-
-class ManualScaleNsReqSerializer(serializers.Serializer):
-    scaleType = serializers.CharField(help_text="Type of NS Scale", required=True)
-    scaleNsData = ScaleNsDataSerializer(help_text="Scale NS data", many=True)
index 533aa1c..437c52a 100644 (file)
@@ -14,6 +14,7 @@
 
 from rest_framework import serializers
 from lcm.ns.serializers.common_Link import LinkSerializer
+from lcm.ns_pnfs.serializers.pnf_serializer import PnfInstanceSerializer
 
 
 class AddressRangeSerializer(serializers.Serializer):
@@ -66,3 +67,47 @@ 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)
+
+
+class NsOperateJobSerializer(serializers.Serializer):
+    jobId = serializers.CharField(help_text="ID of NS operate job", required=True)
+
+
+class VnfInstSerializer(serializers.Serializer):
+    vnfInstanceId = serializers.CharField(help_text="ID of VNF instance", required=True)
+    vnfInstanceName = serializers.CharField(help_text="Name of VNF instance", required=False, allow_null=True, allow_blank=True)
+    vnfdId = serializers.CharField(help_text="ID of VNFD", required=False, allow_null=True, allow_blank=True)
+
+
+class CpInstInfoSerializer(serializers.Serializer):
+    cpInstanceId = serializers.CharField(help_text="ID of CP instance", required=True)
+    cpInstanceName = serializers.CharField(help_text="Name of CP instance", required=False, allow_null=True, allow_blank=True)
+    cpdId = serializers.CharField(help_text="ID of CPD", required=False, allow_null=True, allow_blank=True)
+
+
+class VlInstSerializer(serializers.Serializer):
+    vlInstanceId = serializers.CharField(help_text="ID of VL instance", required=True)
+    vlInstanceName = serializers.CharField(help_text="Name of VL instance", required=False, allow_null=True, allow_blank=True)
+    vldId = serializers.CharField(help_text="ID of VLD", required=False, allow_null=True, allow_blank=True)
+    relatedCpInstanceId = CpInstInfoSerializer(help_text="Related CP instances", many=True)
+
+
+class VnffgInstSerializer(serializers.Serializer):
+    vnffgInstanceId = serializers.CharField(help_text="ID of VNFFG instance", required=True)
+    vnfdId = serializers.CharField(help_text="ID of VNFD", required=False, allow_null=True, allow_blank=True)
+    pnfId = serializers.CharField(help_text="ID of PNF", required=False, allow_null=True, allow_blank=True)
+    virtualLinkId = serializers.CharField(help_text="ID of virtual link", required=False, allow_null=True, allow_blank=True)
+    cpdId = serializers.CharField(help_text="ID of CPD", required=False, allow_null=True, allow_blank=True)
+    nfp = serializers.CharField(help_text="nfp", required=False, allow_null=True, allow_blank=True)
+
+
+class QueryNsRespSerializer(serializers.Serializer):
+    nsInstanceId = serializers.CharField(help_text="ID of NS instance", required=True)
+    nsName = serializers.CharField(help_text="Name of NS instance", required=False, allow_null=True, allow_blank=True)
+    description = serializers.CharField(help_text="Description of NS instance", required=False, allow_null=True, allow_blank=True)
+    nsdId = serializers.CharField(help_text="ID of NSD", required=True)
+    vnfInfo = VnfInstSerializer(help_text="VNF instances", many=True, required=False, allow_null=True)
+    pnfInfo = PnfInstanceSerializer(help_text="PNF instances", many=True, required=False, allow_null=True)
+    vlInfo = VlInstSerializer(help_text="VL instances", many=True, required=False, allow_null=True)
+    vnffgInfo = VnffgInstSerializer(help_text="VNFFG instances", many=True, required=False, allow_null=True)
+    nsState = serializers.CharField(help_text="State of NS instance", required=False, allow_null=True, allow_blank=True)
index fe19895..cd206b9 100644 (file)
@@ -178,3 +178,8 @@ class ScaleNsRequestSerializer(serializers.Serializer):
                                          required=False, allow_null=True)
     scaleTime = serializers.CharField(help_text="Timestamp indicating the scale time of the NS",
                                       required=False, allow_null=True)
+
+
+class ManualScaleNsReqSerializer(serializers.Serializer):
+    scaleType = serializers.CharField(help_text="Type of NS Scale", required=True)
+    scaleNsData = ScaleNsDataSerializer(help_text="Scale NS data", many=True)
diff --git a/lcm/ns/serializers/terminate_ns_serializer.py b/lcm/ns/serializers/terminate_ns_serializer.py
new file mode 100644 (file)
index 0000000..d669a6b
--- /dev/null
@@ -0,0 +1,22 @@
+# 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
+
+
+class TerminateNsReqSerializer(serializers.Serializer):
+    terminationType = serializers.CharField(help_text="Type of NS termination",
+                                            required=False, allow_null=True, allow_blank=True)
+    gracefulTerminationTimeout = serializers.CharField(help_text="Timeout of NS graceful termination",
+                                                       required=False, allow_null=True, allow_blank=True)
index 020ded0..2da3535 100644 (file)
@@ -1,6 +1,7 @@
 # Copyright (c) 2018, 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.
+# 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
index c4fbf98..2ebccea 100644 (file)
@@ -4,7 +4,7 @@
 # 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
+# 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,
index df4f403..1ccced1 100644 (file)
@@ -4,7 +4,7 @@
 # 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
+# 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,
index 6aae1f8..e03ed95 100644 (file)
@@ -22,7 +22,7 @@ from drf_yasg.utils import swagger_auto_schema
 from lcm.ns.biz.ns_create import CreateNSService
 from lcm.ns.biz.ns_get import GetNSInfoService
 from lcm.ns.serializers.create_ns_serializers import CreateNsReqSerializer, CreateNsRespSerializer
-from lcm.ns.serializers.ns_serializers import QueryNsRespSerializer
+from lcm.ns.serializers.pub_serializers import QueryNsRespSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.values import ignore_case_get
 
index 02cfdc9..ce0692e 100644 (file)
@@ -21,7 +21,7 @@ from drf_yasg.utils import swagger_auto_schema
 
 from lcm.ns.biz.ns_get import GetNSInfoService
 from lcm.ns.biz.ns_delete import DeleteNsService
-from lcm.ns.serializers.ns_serializers import QueryNsRespSerializer
+from lcm.ns.serializers.pub_serializers import QueryNsRespSerializer
 from lcm.pub.exceptions import NSLCMException
 
 logger = logging.getLogger(__name__)
index 71242bc..9133b8e 100644 (file)
@@ -20,7 +20,7 @@ from drf_yasg.utils import swagger_auto_schema
 
 from lcm.ns.biz.ns_heal import NSHealService
 from lcm.ns.serializers.heal_serializers import HealNsReqSerializer
-from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.pub_serializers import NsOperateJobSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 
index ff78adc..865b449 100644 (file)
@@ -20,7 +20,7 @@ from rest_framework.response import Response
 from rest_framework.views import APIView
 from drf_yasg.utils import swagger_auto_schema
 
-from lcm.ns.serializers.ns_serializers import InstNsPostDealReqSerializer
+from lcm.ns.serializers.inst_ns_serializers import InstNsPostDealReqSerializer
 from lcm.pub.database.models import NSInstModel, ServiceBaseInfoModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.restcall import req_by_msb
index ce704d3..eddd9a9 100644 (file)
@@ -20,7 +20,7 @@ from drf_yasg.utils import swagger_auto_schema
 
 from lcm.ns.biz.ns_instant import InstantNSService
 from lcm.ns.serializers.inst_ns_serializers import InstantNsReqSerializer
-from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.pub_serializers import NsOperateJobSerializer
 
 logger = logging.getLogger(__name__)
 
index 6a9050c..9b0da9e 100644 (file)
@@ -20,8 +20,8 @@ from rest_framework.views import APIView
 from drf_yasg.utils import swagger_auto_schema
 
 from lcm.ns.biz.ns_manual_scale import NSManualScaleService
-from lcm.ns.serializers.ns_serializers import ManualScaleNsReqSerializer
-from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.scale_ns_serializers import ManualScaleNsReqSerializer
+from lcm.ns.serializers.pub_serializers import NsOperateJobSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 
index aa9a864..0ae655b 100644 (file)
@@ -19,8 +19,8 @@ from rest_framework.views import APIView
 from drf_yasg.utils import swagger_auto_schema
 
 from lcm.ns.biz.ns_terminate import TerminateNsService
-from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
-from lcm.ns.serializers.ns_serializers import TerminateNsReqSerializer
+from lcm.ns.serializers.pub_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.terminate_ns_serializer import TerminateNsReqSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 from lcm.pub.utils.values import ignore_case_get
index 47930ab..9c2276d 100644 (file)
@@ -18,9 +18,8 @@ from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
 from drf_yasg.utils import swagger_auto_schema
-
 from lcm.ns.biz.ns_update import NSUpdateService
-from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.pub_serializers import NsOperateJobSerializer
 from lcm.ns.serializers.update_serializers import UpdateNsReqSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE