seperate sol and deprecated serializers 95/83095/3
authormaopengzhang <zhang.maopeng1@zte.com.cn>
Sat, 23 Mar 2019 05:53:44 +0000 (13:53 +0800)
committermaopengzhang <zhang.maopeng1@zte.com.cn>
Sat, 23 Mar 2019 06:20:44 +0000 (14:20 +0800)
seperate sol and deprecated serializers

Change-Id: I78e82d07d83c8bc0f1a5e1465b198a8c73be9fbb
Issue-ID: VFC-1211
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
27 files changed:
lcm/ns/serializers/sol/cp_serializers.py [new file with mode: 0644]
lcm/ns/serializers/sol/create_ns_serializers.py
lcm/ns/serializers/sol/ext_link_port_info.py [deleted file]
lcm/ns/serializers/sol/ext_managed_virtual_link_info.py [new file with mode: 0644]
lcm/ns/serializers/sol/ext_virtual_link_info.py
lcm/ns/serializers/sol/inst_ns_serializers.py
lcm/ns/serializers/sol/lccn_subscription.py
lcm/ns/serializers/sol/lccn_subscriptions.py [deleted file]
lcm/ns/serializers/sol/link.py [deleted file]
lcm/ns/serializers/sol/ns_instance.py [new file with mode: 0644]
lcm/ns/serializers/sol/ns_lcm_op_occ.py
lcm/ns/serializers/sol/ns_lcm_op_occs.py [deleted file]
lcm/ns/serializers/sol/pub_serializers.py
lcm/ns/serializers/sol/response.py [deleted file]
lcm/ns/serializers/sol/scale_ns_serializers.py
lcm/ns/serializers/sol/update_serializers.py
lcm/ns/views/sol/heal_ns_view.py
lcm/ns/views/sol/instantiate_ns_views.py
lcm/ns/views/sol/lcm_op_occs_view.py
lcm/ns/views/sol/ns_instances_views.py
lcm/ns/views/sol/scale_ns_views.py
lcm/ns/views/sol/subscriptions_view.py
lcm/ns/views/sol/terminate_ns_view.py
lcm/ns/views/sol/update_ns_view.py
lcm/ns_vnfs/serializers/grant_vnf_serializer.py
lcm/pub/exceptions.py
lcm/settings.py

diff --git a/lcm/ns/serializers/sol/cp_serializers.py b/lcm/ns/serializers/sol/cp_serializers.py
new file mode 100644 (file)
index 0000000..8e541ae
--- /dev/null
@@ -0,0 +1,103 @@
+# 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 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 IpAddressesDataSerialzier(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 IpAddressesInfoSerialzier(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 IpOverEthernetAddressDataSerializer(serializers.Serializer):
+    macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
+    ipAddresses = IpAddressesDataSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+                                            required=False, allow_null=True, many=True)
+
+
+class IpOverEthernetAddressInfoSerializer(serializers.Serializer):
+    macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
+    ipAddresses = IpAddressesInfoSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+                                            required=False, allow_null=True, many=True)
+
+
+class CpProtocolDataSerializer(serializers.Serializer):
+    layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
+                                            choices=["IP_OVER_ETHERNET"], required=True)
+    ipOverEthernet = IpOverEthernetAddressDataSerializer(help_text="Network address data for IP over Ethernet"
+                                                                   "to assign to the extCP instance.",
+                                                         required=False, allow_null=True)
+
+
+class CpProtocolInfoSerializer(serializers.Serializer):
+    layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
+                                            choices=["IP_OVER_ETHERNET"], required=True)
+    ipOverEthernet = IpOverEthernetAddressInfoSerializer(help_text="Network address data for IP over Ethernet"
+                                                                   "to assign to the extCP instance.",
+                                                         required=False, allow_null=True)
+
+
+class VnfExtCpInfoSerializer(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=True,
+        allow_blank=False)
+    cpdId = serializers.CharField(
+        help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.",
+        max_length=255,
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    cpProtocolInfo = CpProtocolInfoSerializer(
+        help_text="Network protocol information for this CP.",
+        many=True,
+        required=False,
+        allow_null=True)
+    extLinkPortId = serializers.CharField(
+        help_text="Identifier of the extLinkPortInfo structure inside the extVirtualLinkInfo structure.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
index 915323c..c335ee2 100644 (file)
 
 from rest_framework import serializers
 
-from lcm.ns.serializers.sol.pub_serializers import Links, ipAddressesSerializer, CpProtocolDataSerializer
-from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
-
 
 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)
+    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=False, allow_null=True)
     nsDescription = serializers.CharField(help_text="Description of NS", required=False, allow_null=True)
-
-
-class VnfInstanceSerializer(serializers.Serializer):
-    id = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
-    vnfInstanceName = serializers.CharField(help_text="Name of the VNF instance.", required=False,
-                                            allow_null=True)
-
-
-class PnfExtCpInfoSerializer(serializers.Serializer):
-    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)
-
-    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)
-
-
-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)
-    resourceHandle = ResourceHandleSerializer(help_text="Identifier(s) of the virtualised network resource(s)"
-                                                        " realizing the VL instance",
-                                              required=True, many=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)
-
-
-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)
-
-
-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)
-
-
-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)
-
-
-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)
-
-
-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.",
-                                        required=False, allow_null=True, 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)
-    ipOverEthernet = IpOverEthernetAddressInfoSerializer(help_text="IP addresses over Ethernet to assign to"
-                                                                   "the CPor SAP instance.",
-                                                         required=False, allow_null=True)
-
-
-class SapInfoSerializer(serializers.Serializer):
-    id = serializers.CharField(help_text="Identifier of the SAP instance.", required=True)
-    sapdId = serializers.CharField(help_text="Identifier of the SAPD in the NSD.", required=True)
-    sapName = serializers.CharField(help_text="Human readable name for the SAP instance.", required=True)
-    description = serializers.CharField(help_text="Human readable description for the SAP instance.",
-                                        required=True)
-    sapProtocolInfo = CpProtocolInfoSerializer(help_text="Network protocol information for this SAP.",
-                                               required=True, many=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)
-
-
-class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
-    vnfdId = serializers.ListField(help_text="Reference to a VNFD.",
-                                   child=serializers.CharField(help_text="Identifier of the vnfd"),
-                                   required=False, allow_null=True)
-    vnfProfileId = serializers.ListField(help_text="Reference to a vnfProfile defined in the NSD.",
-                                         child=serializers.CharField(
-                                             help_text="Identifier of the vnfProfile"), required=True)
-    vnfInstanceId = serializers.ListField(help_text="Reference to the existing VNF instance as the subject of"
-                                                    "the affinity or anti-affinity rule",
-                                          child=serializers.CharField(help_text="identifier of the"
-                                                                                "vnfInstanceId"),
-                                          required=False, allow_null=True)
-    affinityOrAntiAffiinty = serializers.ChoiceField(help_text="The type of the constraint.",
-                                                     choices=["AFFINITY", "ANTI_AFFINITY"], required=True)
-    scope = serializers.ChoiceField(help_text="Specifies the scope of the rule where the placement"
-                                              "constraint applies.",
-                                    choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"], required=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)
-    nsInstanceDescription = serializers.CharField(help_text="Human readable description of the NS instance.",
-                                                  required=True)
-    nsdId = serializers.CharField(help_text="Identifier of the NSD on which the NS instance is based.",
-                                  required=True)
-    nsdInfoId = serializers.CharField(help_text="Identifier of the NSD information object on which the "
-                                                "NS instance is based.", required=True)
-    flavourId = serializers.CharField(help_text="Identifier of the NS deployment flavour applied to "
-                                                "the NS instance.", required=False, allow_null=True)
-    vnfInstance = VnfInstanceSerializer(help_text="Information on constituent VNF(s) of the NS instance.",
-                                        required=False, allow_null=True, many=True)
-
-    pnfInfo = PnfInfoSerializer(help_text="Information on the PNF(s) that are part of the NS instance.",
-                                required=False, allow_null=True, many=True)
-    virtualLinkInfo = NsVirtualLinkInfoSerializer(help_text="Information on the VL(s) of the NS instance.",
-                                                  required=False, allow_null=True, many=True)
-    vnffgInfo = VnffgInfoSerializer(help_text="Information on the VNFFG(s) of the NS instance",
-                                    required=False, allow_null=True, many=True)
-    sapInfo = SapInfoSerializer(help_text="Information on the SAP(s) of the NS instance",
-                                required=False, allow_null=True, many=True)
-    nestedNsInstanceId = serializers.ListField(help_text="Identifier of the nested NS(s) of the NS instance.",
-                                               child=serializers.CharField(help_text="nested of the NS"
-                                                                                     "instance",),
-                                               required=False, allow_null=True)
-    nsState = serializers.ChoiceField(help_text="The state of the NS instance.", required=True,
-                                      choices=["NOT_INSTANTIATED", "INSTANTIATED"])
-    nsScaleStatus = NsScaleInfoSerializer(help_text="Status of each NS scaling aspect declared in the"
-                                                    "applicable DF, how 'big' the NS instance has been"
-                                                    "scaled w.r.t. that aspect.",
-                                          required=False, allow_null=True, many=True)
-    additionalAffinityOrAntiAffinityRule = AffinityOrAntiAffinityRuleSerializer(
-        help_text="Information on the additional affinity or anti-affinity rule from NS instantiation "
-                  "operation.", required=False, allow_null=True, many=True)
-    _links = Links(help_text="Links to resources related to this resource.", required=True)
diff --git a/lcm/ns/serializers/sol/ext_link_port_info.py b/lcm/ns/serializers/sol/ext_link_port_info.py
deleted file mode 100644 (file)
index fc13f82..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# 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.sol.resource_handle import ResourceHandleSerializer
-
-
-class ExtlinkPortInfoSerializer(serializers.Serializer):
-    id = serializers.CharField(
-        help_text="Identifier of this link port as provided by the entity that has created the link port.",
-        max_length=255,
-        required=True,
-        allow_blank=False,
-        allow_null=False)
-    resourceHandle = ResourceHandleSerializer(
-        help_text="Reference to the virtualised resource realizing this link port.",
-        required=True,
-        allow_null=False)
-    cpInstanceId = serializers.CharField(
-        help_text="Identifier of the external CP of the VNFconnected to this link port.",
-        max_length=255,
-        required=False,
-        allow_blank=True,
-        allow_null=True)
diff --git a/lcm/ns/serializers/sol/ext_managed_virtual_link_info.py b/lcm/ns/serializers/sol/ext_managed_virtual_link_info.py
new file mode 100644 (file)
index 0000000..72a98ce
--- /dev/null
@@ -0,0 +1,56 @@
+# 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 rest_framework import serializers
+from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
+
+
+class VnfLinkPortInfo(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this link port as provided by the entity that has created the link port.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    resourceHandle = ResourceHandleSerializer(
+        help_text="Reference to the virtualised network resource realizing this link port.",
+        required=True,
+        allow_null=False)
+    cpInstanceId = serializers.CharField(
+        help_text="When the link port is used for external connectivity by the VNF, \
+        this attribute represents the identifier of the external CP of the VNF to be connected to this link port.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    cpInstanceType = serializers.ChoiceField(required=False, choices=['VNFC_CP', 'EXT_CP'], help_text="Type of the CP instance that is identified by cpInstanceId."),
+
+
+class ExtManagedVirtualLinkInfo(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of the externally-managed inner VL and the related externally-managed VL information instance.",
+        max_length=255,
+        required=True)
+    vnfVirtualLinkDescId = serializers.CharField(
+        help_text="Identifier of the VNF Virtual Link Descriptor (VLD) in the VNFD.",
+        max_length=255,
+        required=True)
+    networkResource = ResourceHandleSerializer(
+        help_text="ResourceHandle,reference to the VirtualNetwork resource.",
+        required=True,
+        allow_null=False)
+    vnfLinkPorts = VnfLinkPortInfo(
+        help_text="VnfLinkPortInfo, Link ports of this VL.",
+        many=True,
+        required=False)
index edb8004..94138b8 100644 (file)
 # limitations under the License.
 
 from rest_framework import serializers
-
-from lcm.ns.serializers.sol.ext_link_port_info import ExtlinkPortInfoSerializer
 from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
 
 
+class ExtlinkPortInfoSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this link port as provided by the entity that has created the link port.",
+        max_length=255,
+        required=True,
+        allow_blank=False,
+        allow_null=False)
+    resourceHandle = ResourceHandleSerializer(
+        help_text="Reference to the virtualised resource realizing this link port.",
+        required=True,
+        allow_null=False)
+    cpInstanceId = serializers.CharField(
+        help_text="Identifier of the external CP of the VNFconnected to this link port.",
+        max_length=255,
+        required=False,
+        allow_blank=True,
+        allow_null=True)
+
+
 class ExtVirtualLinkInfoSerializer(serializers.Serializer):
     id = serializers.CharField(
         help_text="Identifier of the external VL and the related external VL information instance.",
index 5f189c6..fd64a00 100644 (file)
@@ -14,7 +14,7 @@
 
 from rest_framework import serializers
 
-from lcm.ns.serializers.sol.create_ns_serializers import AffinityOrAntiAffinityRuleSerializer
+from lcm.ns.serializers.sol.pub_serializers import AffinityOrAntiAffinityRuleSerializer
 from lcm.ns.serializers.sol.update_serializers import AddPnfDataSerializer, VnfInstanceDataSerializer, SapDataSerializer
 
 
@@ -85,7 +85,3 @@ 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)
index 5211784..42a9eb1 100644 (file)
 from rest_framework import serializers
 
 from lcm.ns.serializers.sol.lccn_filter_data import LifeCycleChangeNotificationsFilter
-from lcm.ns.serializers.sol.link import linkSerializer
+from lcm.ns.serializers.sol.pub_serializers import LinkSerializer
 
 
-class LinkSerializer(serializers.Serializer):
-    self = linkSerializer(
+class LccnSubscriptionLinkSerializer(serializers.Serializer):
+    self = LinkSerializer(
         help_text="URI of this resource.",
         required=True,
         allow_null=False)
@@ -40,5 +40,9 @@ class LccnSubscriptionSerializer(serializers.Serializer):
         help_text="Filter settings for this subscription, to define the of all notifications this "
                   "subscription relates to A particular notification is sent to the subscriber if the filter"
                   " matches, or if there is no filter.", required=False)
-    _links = LinkSerializer(
+    _links = LccnSubscriptionLinkSerializer(
         help_text="Links to resources related to this resource.", required=True)
+
+
+class LccnSubscriptionsSerializer(serializers.ListSerializer):
+    child = LccnSubscriptionSerializer()
diff --git a/lcm/ns/serializers/sol/lccn_subscriptions.py b/lcm/ns/serializers/sol/lccn_subscriptions.py
deleted file mode 100644 (file)
index 82a8038..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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 lccn_subscription import LccnSubscriptionSerializer
-
-
-class LccnSubscriptionsSerializer(serializers.ListSerializer):
-    child = LccnSubscriptionSerializer()
diff --git a/lcm/ns/serializers/sol/link.py b/lcm/ns/serializers/sol/link.py
deleted file mode 100644 (file)
index a976f6a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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 linkSerializer(serializers.Serializer):
-    href = serializers.CharField(
-        help_text="URI of the referenced resource.", required=True, allow_null=False, allow_blank=False)
diff --git a/lcm/ns/serializers/sol/ns_instance.py b/lcm/ns/serializers/sol/ns_instance.py
new file mode 100644 (file)
index 0000000..73340bf
--- /dev/null
@@ -0,0 +1,650 @@
+# 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 rest_framework import serializers
+
+from lcm.ns.serializers.sol.pub_serializers import LinkSerializer
+from lcm.ns.serializers.sol.cp_serializers import CpProtocolDataSerializer, CpProtocolInfoSerializer, VnfExtCpInfoSerializer
+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
+from lcm.ns.serializers.sol.pub_serializers import AffinityOrAntiAffinityRuleSerializer
+
+INSTANTIATION_STATE = [
+    "NOT_INSTANTIATED",
+    "INSTANTIATED"
+]
+
+
+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)
+
+
+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)
+
+
+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)
+    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)
+    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)
+    cpProtocolInfo = CpProtocolInfoSerializer(
+        help_text="Network protocol information for this CP.",
+        many=True,
+        required=False,
+        allow_null=True)
+    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)
+
+
+class VnfcResourceInfoSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this VnfcResourceInfo instance.",
+        max_length=255,
+        required=False,
+        allow_null=False)
+    vduId = serializers.CharField(
+        help_text="Reference to the applicable VDU in the VNFD.",
+        max_length=255,
+        required=False,
+        allow_null=False)
+    computeResource = ResourceHandleSerializer(
+        help_text="Reference to the VirtualCompute resource.",
+        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.",
+        child=serializers.CharField(help_text="Identifier In Vnf", allow_blank=True),
+        required=False,
+        allow_null=True)
+    reservationId = serializers.CharField(
+        help_text="The reservation identifier applicable to the resource.",
+        max_length=255,
+        required=False,
+        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.",
+        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)
+
+
+class VnfLinkPortInfo(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this link port as provided by the entity that has created the link port.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    resourceHandle = ResourceHandleSerializer(
+        help_text="Reference to the virtualised network resource realizing this link port.",
+        required=True,
+        allow_null=False)
+    cpInstanceId = serializers.CharField(
+        help_text="When the link port is used for external connectivity by the VNF, \
+        this attribute represents the identifier of the external CP of the VNF to be connected to this link port.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+
+
+class VnfVirtualLinkResourceInfoSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this VnfVirtualLinkResourceInfo instance.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    virtualLinkDescId = serializers.CharField(
+        help_text="Identifier of the VNF Virtual Link Descriptor (VLD) in the VNFD.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    networkResource = ResourceHandleSerializer(
+        help_text="Reference to the VirtualNetwork resource.",
+        required=True,
+        allow_null=False)
+    reservationId = serializers.CharField(
+        help_text="The reservation identifier applicable to the resource.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfLinkPorts = VnfLinkPortInfo(
+        help_text="Links ports of this VL. \
+        Shall be present when the linkPort is used for external connectivity by the VNF",
+        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)
+
+
+class VirtualStorageResourceInfoSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this VirtualStorageResourceInfo instance.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    virtualStorageDescId = serializers.CharField(
+        help_text="Identifier of the VirtualStorageDesc in the VNFD.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    storageResource = ResourceHandleSerializer(
+        help_text="Reference to the VirtualStorage resource.",
+        required=True,
+        allow_null=False)
+    reservationId = serializers.CharField(
+        help_text="The reservation identifier applicable to the resource.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=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)
+
+
+class InstantiatedVnfInfo(serializers.Serializer):
+    flavourId = serializers.CharField(
+        help_text="Identifier of the VNF deployment flavour applied to this VNF instance.",
+        max_length=255,
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    vnfState = serializers.ChoiceField(
+        help_text="State of the VNF instance.",
+        choices=["STARTED", "STOPPED"],
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    scaleStatus = VnfScaleInfoSerializer(
+        help_text="Scale status of the VNF, one entry per aspect. \
+        Represents for every scaling aspect how big the VNF has been scaled w.r.t. that aspect.",
+        many=True,
+        required=False,
+        allow_null=True)
+    extCpInfo = VnfExtCpInfoSerializer(
+        help_text="Information about the external CPs exposed by the VNF instance.",
+        many=True,
+        required=True,
+        allow_null=False)
+    extVirtualLinkInfo = ExtVirtualLinkInfoSerializer(
+        help_text="Information about the external VLs the VNF instance is connected to.",
+        many=True,
+        required=False,
+        allow_null=True)
+    extManagedVirtualLinkInfo = ExtManagedVirtualLinkInfo(
+        help_text="Information about the externally-managed inner VLs of the VNF instance.",
+        many=True,
+        required=False,
+        allow_null=True)
+    monitoringParameters = serializers.DictField(
+        help_text="Active monitoring parameters.",
+        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
+        required=False,
+        allow_null=True)
+    localizationLanguage = serializers.CharField(
+        help_text="Information about localization language of the VNF.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfcResourceInfo = VnfcResourceInfoSerializer(
+        help_text="Information about the virtualised compute and storage resources used by the VNFCs of the VNF instance.",
+        many=True,
+        required=False,
+        allow_null=True)
+    vnfVirtualLinkResourceInfo = VnfVirtualLinkResourceInfoSerializer(
+        help_text="Information about the virtualised network resources used by the VLs of the VNF instance.",
+        many=True,
+        required=False,
+        allow_null=True)
+    virtualStorageResourceInfo = VirtualStorageResourceInfoSerializer(
+        help_text="Information about the virtualised storage resources used as storage for the VNF instance.",
+        many=True,
+        required=False,
+        allow_null=True)
+
+
+class VnfInstanceLinks(serializers.Serializer):
+    href = LinkSerializer(
+        help_text="URI of this resource.",
+        required=True,
+        allow_null=False)
+    indicators = LinkSerializer(
+        help_text="Indicators related to this VNF instance.",
+        required=False,
+        allow_null=True)
+    instantiate = LinkSerializer(
+        help_text="Link to the instantiate task resource.",
+        required=False,
+        allow_null=True)
+    termiante = LinkSerializer(
+        help_text="Link to the terminate task resource.",
+        required=False,
+        allow_null=True)
+    scale = LinkSerializer(
+        help_text="Link to the scale task resource.",
+        required=False,
+        allow_null=True)
+    scaleToLevel = LinkSerializer(
+        help_text="Link to the scale_to_level task resource.",
+        required=False,
+        allow_null=True)
+    changeFlavour = LinkSerializer(
+        help_text="Link to the change_flavour task resource.",
+        required=False,
+        allow_null=True)
+    heal = LinkSerializer(
+        help_text="Link to the heal task resource.",
+        required=False,
+        allow_null=True)
+    operate = LinkSerializer(
+        help_text="Link to the operate task resource.",
+        required=False,
+        allow_null=True)
+    changeExtConn = LinkSerializer(
+        help_text="Link to the change_ext_conn task resource.",
+        required=False,
+        allow_null=True)
+
+
+class VnfInstanceSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of the VNF instance.",
+        max_length=255,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    vnfInstanceName = serializers.CharField(
+        help_text="Name of the VNF instance.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfInstanceDescription = serializers.CharField(
+        help_text="Human-readable description of the VNF instance.",
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfdId = serializers.CharField(
+        help_text="Identifier of the VNFD on which the VNF instance is based.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfProvider = serializers.CharField(
+        help_text="Provider of the VNF and the VNFD.",
+        max_length=255,
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    vnfProductName = serializers.CharField(
+        help_text="Name to identify the VNF Product.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfSoftwareVersion = serializers.CharField(
+        help_text="Software version of the VNF.",
+        max_length=255,
+        required=False,
+        allow_null=True,
+        allow_blank=True)
+    vnfdVersion = serializers.CharField(
+        help_text="Identifies the version of the VNFD.",
+        max_length=255,
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    vnfPkgId = serializers.CharField(
+        help_text="Identifier of information held by the NFVO about the specific VNF package on which the VNF is based. \
+        This attribute can be modified with the PATCH method.",
+        max_length=255,
+        required=True,
+        allow_null=True,
+        allow_blank=False)
+    vnfConfigurableProperties = serializers.DictField(
+        help_text="Current values of the configurable properties of the VNF instance. \
+        Configurable properties referred in this attribute are declared in the VNFD",
+        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
+        required=False,
+        allow_null=True,)
+    vimId = serializers.ListField(
+        help_text="Identifier set of a VIM that manages resources for the VNF instance.",
+        child=serializers.CharField(help_text="Identifier of a VIM that manages resources for the VNF instance.", allow_null=False),
+        required=False)
+    instantiationState = serializers.ChoiceField(
+        help_text="The instantiation state of the VNF.",
+        choices=INSTANTIATION_STATE,
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    instantiatedVnfInfo = InstantiatedVnfInfo(
+        help_text="Information specific to an instantiated VNF instance. \
+        This attribute shall be present if the instantiateState attribute value is INSTANTIATED",
+        required=False,
+        allow_null=True)
+    metadata = serializers.DictField(
+        help_text="Additional VNF-specific metadata describing the VNF instance.\
+        This attribute can be modified with the PATCH method.",
+        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
+        required=False,
+        allow_null=True)
+    extensions = serializers.DictField(
+        help_text="VNF-specific attributes that affect the lifecycle management of this VNF instance by the VNFM, or the lifecycle management scripts. \
+        This attribute can be modified with the PATCH method.",
+        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
+        required=False,
+        allow_null=True)
+    _links = VnfInstanceLinks(
+        help_text="Links to resources related to this resource.",
+        required=False,
+        allow_null=False)
+
+
+class PnfExtCpInfoSerializer(serializers.Serializer):
+    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)
+
+    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)
+
+
+class NsLinkPortInfo(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this link port as provided by the entity that has created the link port.",
+        max_length=255,
+        required=True,
+        allow_blank=False,
+        allow_null=False)
+    resourceHandle = ResourceHandleSerializer(
+        help_text="Reference to the virtualised resource realizing this link port.",
+        required=True,
+        allow_null=False)
+    cpInstanceId = serializers.CharField(
+        help_text="Identifier of the external CP of the VNF connected to this link port. \
+        There shall be at most one link port associated with any external connection point instance.",
+        max_length=255,
+        required=False,
+        allow_blank=True,
+        allow_null=True)
+
+
+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)
+
+
+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)
+
+
+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)
+
+
+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)
+
+
+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)
+
+
+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)
+
+
+class SapInfo(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of the SAP instance.",
+        required=True)
+    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)
+    sapProtocolInfo = CpProtocolInfoSerializer(
+        help_text="Parameters for configuring the network protocols on the SAP.",
+        many=True,
+        required=False,
+        allow_null=True)
+
+
+class NsLinkSerializer(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,
+        many=True)
+    instantiate = LinkSerializer(
+        help_text="Link to the instantiate task resource.",
+        required=False,
+        allow_null=False)
+    terminate = LinkSerializer(
+        help_text="Link to the terminate task resource.",
+        required=False,
+        allow_null=False)
+    update = LinkSerializer(
+        help_text="Link to the update task resource.",
+        required=False,
+        allow_null=False)
+    scale = LinkSerializer(
+        help_text="Link to the scale task resource.",
+        required=False,
+        allow_null=False)
+    heal = LinkSerializer(
+        help_text="Link to the heal task resource.",
+        required=False,
+        allow_null=False)
+
+
+class NsInstanceSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of the NS instance.",
+        required=True)
+    nsInstanceName = serializers.CharField(
+        help_text="Human readable name of the NS instance.",
+        required=True)
+    nsInstanceDescription = serializers.CharField(
+        help_text="Human readable description of the NS instance.",
+        required=True)
+    nsdId = serializers.CharField(
+        help_text="Identifier of the NSD on which the NS instance is based.",
+        required=True)
+    nsdInfoId = serializers.CharField(
+        help_text="Identifier of the NSD information object on which the NS instance is based.",
+        required=True)
+    flavourId = serializers.CharField(
+        help_text="Identifier of the NS deployment flavour applied to the NS instance.",
+        required=False)
+    vnfInstance = VnfInstanceSerializer(
+        help_text="Information on constituent VNF(s) of the NS instance.",
+        required=False,
+        many=True)
+    pnfInfo = PnfInfoSerializer(
+        help_text="Information on constituent PNF(s) of the NS instance.",
+        required=False,
+        many=True)
+    virtualLinkInfo = NsVirtualLinkInfoSerializer(
+        help_text="Information on the VL(s) of the NS instance.",
+        required=False,
+        many=True)
+    vnffgInfo = VnffgInfoSerializer(
+        many=True,
+        required=False,
+        help_text="VNF Forward Graph Information.")
+    sapInfo = SapInfo(
+        many=True,
+        required=False,
+        help_text="Create data concerning the SAPs.")
+    nestedNsInstanceId = serializers.ListField(
+        help_text="Identifier of the nested NS(s) of the NS instance.",
+        child=serializers.CharField(),
+        required=False,
+        allow_null=True
+    )
+    nsState = serializers.ChoiceField(
+        help_text="The state of the NS instance.",
+        choices=["NOT_INSTANTIATED", "INSTANTIATED"],
+        required=True,
+        allow_null=True)
+    nsScaleStatus = NsScaleInfoSerializer(
+        help_text="Status of each NS scaling aspect declared in the applicable DF.",
+        required=False,
+        many=True)
+    additionalAffinityOrAntiAffinityRule = AffinityOrAntiAffinityRuleSerializer(
+        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)
index b68486d..9ccf920 100644 (file)
@@ -22,8 +22,8 @@ from lcm.ns.serializers.sol.affected_saps import AffectedSapsSerializer
 from lcm.ns.serializers.sol.affected_vls import AffectedVLsSerializer
 from lcm.ns.serializers.sol.affected_vnffgs import AffectedVnffgsSerializer
 from lcm.ns.serializers.sol.affected_vnfs import AffectedVnfsSerializer
-from lcm.ns.serializers.sol.link import linkSerializer
-from lcm.ns.serializers.sol.response import ProblemDetailsSerializer
+from lcm.ns.serializers.sol.pub_serializers import LinkSerializer
+from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer
 
 
 class ResourceChangesSerializer(serializers.Serializer):
@@ -60,7 +60,7 @@ class ResourceChangesSerializer(serializers.Serializer):
 
 
 class LcmOpLinkSerializer(serializers.Serializer):
-    self = linkSerializer(
+    self = LinkSerializer(
         help_text="URI of this resource.",
         required=True,
         allow_null=False)
@@ -152,3 +152,7 @@ class NSLCMOpOccSerializer(serializers.Serializer):
     _links = LcmOpLinkSerializer(
         help_text="Links to resources related to this resource.",
         required=True)
+
+
+class NSLCMOpOccsSerializer(serializers.ListSerializer):
+    child = NSLCMOpOccSerializer()
diff --git a/lcm/ns/serializers/sol/ns_lcm_op_occs.py b/lcm/ns/serializers/sol/ns_lcm_op_occs.py
deleted file mode 100644 (file)
index cede4e3..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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 ns_lcm_op_occ import NSLCMOpOccSerializer
-
-
-class NSLCMOpOccsSerializer(serializers.ListSerializer):
-    child = NSLCMOpOccSerializer()
index 7cca598..4825f63 100644 (file)
 # 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.sol.link import linkSerializer
-from lcm.ns_pnfs.serializers.pnf_serializer import PnfInstanceSerializer
-
-
-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)
-
-
-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)
-
 
-class CpProtocolDataSerializer(serializers.Serializer):
-    layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
-                                            choices=["IP_OVER_ETHERNET"], required=True)
-    ipOverEthernet = IpOverEthernetAddressDataSerializer(help_text="Network address data for IP over Ethernet"
-                                                                   "to assign to the extCP instance.",
-                                                         required=False, allow_null=True)
+class ProblemDetailsSerializer(serializers.Serializer):
+    type = serializers.CharField(
+        help_text="A URI reference according to IETF RFC 3986 [5] that identifies the problem type.",
+        required=False,
+        allow_null=True,
+        allow_blank=True
+    )
+    title = serializers.CharField(
+        help_text="A short, human-readable summary of the problem type.",
+        required=False,
+        allow_null=True,
+        allow_blank=True
+    )
+    status = serializers.IntegerField(
+        help_text="The HTTP status code for this occurrence of the problem.",
+        required=True
+    )
+    detail = serializers.CharField(
+        help_text="A human-readable explanation specific to this occurrence of the problem.",
+        required=True
+    )
+    instance = serializers.CharField(
+        help_text="A URI reference that identifies the specific occurrence of the problem.",
+        required=False,
+        allow_null=True,
+        allow_blank=True
+    )
+    additional_details = serializers.ListField(
+        help_text="Any number of additional attributes, as defined in a specification or by an"
+                  " implementation.",
+        required=False,
+        allow_null=True
+    )
+
+
+class LinkSerializer(serializers.Serializer):
+    href = serializers.CharField(
+        help_text="URI of the referenced resource.", required=True, allow_null=False, allow_blank=False)
+
+
+class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
+    vnfdId = serializers.ListField(
+        child=serializers.CharField(),
+        help_text="Identifier of the VNFD on which the VNF instance is based.",
+        required=False,
+        allow_null=True)
+    vnfProfileId = serializers.ListField(
+        child=serializers.CharField(),
+        help_text="Identifier of (Reference to) a vnfProfile defined in the NSD which the existing VNF instance shall be matched with.",
+        required=False,
+        allow_null=True)
+    vnfInstanceId = serializers.ListField(
+        child=serializers.CharField(),
+        help_text="Identifier of the existing VNF instance to be used in the NS.",
+        required=True,
+        allow_null=False)
+    affinityOrAntiAffiinty = serializers.ChoiceField(
+        help_text="The type of the constraint.",
+        choices=["AFFINITY", "ANTI_AFFINITY"],
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+    scope = serializers.ChoiceField(
+        help_text="Specifies the scope of the rule where the placement constraint applies.",
+        choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"],
+        required=True,
+        allow_null=False,
+        allow_blank=False)
diff --git a/lcm/ns/serializers/sol/response.py b/lcm/ns/serializers/sol/response.py
deleted file mode 100644 (file)
index b6f269c..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-# 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 ProblemDetailsSerializer(serializers.Serializer):
-#     type = serializers.CharField(help_text="Type", required=False, allow_null=True)
-#     title = serializers.CharField(help_text="Title", required=False, allow_null=True)
-#     status = serializers.IntegerField(help_text="Status", required=True)
-#     detail = serializers.CharField(help_text="Detail", required=True, allow_null=True)
-#     instance = serializers.CharField(help_text="Instance", required=False, allow_null=True)
-#     additional_details = serializers.ListField(
-#         help_text="Any number of additional attributes, as defined in a specification or by an"
-#                   " implementation.", required=False, allow_null=True)
-
-
-class ProblemDetailsSerializer(serializers.Serializer):
-    type = serializers.CharField(
-        help_text="A URI reference according to IETF RFC 3986 [5] that identifies the problem type.",
-        required=False,
-        allow_null=True,
-        allow_blank=True
-    )
-    title = serializers.CharField(
-        help_text="A short, human-readable summary of the problem type.",
-        required=False,
-        allow_null=True,
-        allow_blank=True
-    )
-    status = serializers.IntegerField(
-        help_text="The HTTP status code for this occurrence of the problem.",
-        required=True
-    )
-    detail = serializers.CharField(
-        help_text="A human-readable explanation specific to this occurrence of the problem.",
-        required=True
-    )
-    instance = serializers.CharField(
-        help_text="A URI reference that identifies the specific occurrence of the problem.",
-        required=False,
-        allow_null=True,
-        allow_blank=True
-    )
-    additional_details = serializers.ListField(
-        help_text="Any number of additional attributes, as defined in a specification or by an"
-                  " implementation.",
-        required=False,
-        allow_null=True
-    )
index 97219cf..a15d1a5 100644 (file)
@@ -14,9 +14,9 @@
 
 from rest_framework import serializers
 
-from lcm.ns.serializers.sol.create_ns_serializers import NsScaleInfoSerializer
 from lcm.ns.serializers.sol.inst_ns_serializers import VnfLocationConstraintSerializer, ParamsForVnfSerializer
 from lcm.ns.serializers.sol.update_serializers import VnfInstanceDataSerializer
+from lcm.ns.serializers.sol.ns_instance import NsScaleInfoSerializer, VnfScaleInfoSerializer
 
 
 # class VnfInstanceDataSerializer(serializers.Serializer):
@@ -36,11 +36,6 @@ class ScaleNsByStepsDataSerializer(serializers.Serializer):
                                                     "to 1. ", required=False, allow_null=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)
-
-
 class ScaleNsToLevelDataSerializer(serializers.Serializer):
     nsInstantiationLevel = serializers.CharField(help_text="Identifier of the target NS instantiation level "
                                                            "of the current DF to which the NS instance is "
@@ -121,11 +116,6 @@ class ScaleNsDataSerializer(serializers.Serializer):
                                                 required=False, allow_null=True)
 
 
-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)
-
-
 class ScaleToLevelDataSerializer(serializers.Serializer):
     vnfInstantiationLevelId = serializers.CharField(help_text="Identifier of the target instantiation level "
                                                               "of the current deployment flavour to which "
index f6079a5..4ddfe8e 100644 (file)
 
 from rest_framework import serializers
 
-from lcm.ns.serializers.sol.create_ns_serializers import ResourceHandleSerializer, NsCpHandleSerializer, \
-    NfpRuleSerializer
-from lcm.ns.serializers.sol.pub_serializers import CpProtocolDataSerializer
-from lcm.ns.serializers.sol.pub_serializers import IpAddressSerialzier
+from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
+from lcm.ns.serializers.sol.ns_instance import NsCpHandleSerializer, NfpRuleSerializer
+from lcm.ns.serializers.sol.cp_serializers import CpProtocolDataSerializer
+from lcm.ns.serializers.sol.cp_serializers import IpAddressesDataSerialzier
 
 
 class VnfInstanceDataSerializer(serializers.Serializer):
@@ -41,8 +41,8 @@ class InstantiateVnfDataSerializer(serializers.Serializer):
 
 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)
+    ipAddresses = IpAddressesDataSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
+                                            required=False, allow_null=True, many=True)
 
 
 class VnfExtCpConfigSerializer(serializers.Serializer):
index 6cd1582..0d39cf6 100644 (file)
@@ -20,7 +20,7 @@ from rest_framework.views import APIView
 
 from lcm.ns.biz.ns_heal import NSHealService
 from lcm.ns.serializers.sol.heal_serializers import HealNsReqSerializer
-from lcm.ns.serializers.sol.pub_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.deprecated.ns_serializers import _NsOperateJobSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 
@@ -31,7 +31,7 @@ class NSHealView(APIView):
     @swagger_auto_schema(
         request_body=HealNsReqSerializer(),
         responses={
-            status.HTTP_202_ACCEPTED: NsOperateJobSerializer(),
+            status.HTTP_202_ACCEPTED: _NsOperateJobSerializer(),
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
         }
     )
@@ -46,7 +46,7 @@ class NSHealView(APIView):
             job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, ns_instance_id)
             NSHealService(ns_instance_id, request.data, job_id).start()
 
-            resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
+            resp_serializer = _NsOperateJobSerializer(data={'jobId': job_id})
             if not resp_serializer.is_valid():
                 raise NSLCMException(resp_serializer.errors)
 
index 104a875..ed43b94 100644 (file)
@@ -19,12 +19,12 @@ logger = logging.getLogger(__name__)
 
 
 class InstantiateNsView(APIView):
-    def post(self, request, id):
+    def post(self, request, ns_instance_id):
         # todo
         return
 
 
 class TerminateNsView(APIView):
-    def post(self, request, id):
+    def post(self, request, ns_instance_id):
         # todo
         return
index dd060a1..4357983 100644 (file)
@@ -22,8 +22,8 @@ from rest_framework.response import Response
 from rest_framework.views import APIView
 
 from lcm.ns.biz.query_ns_lcm_op_occ import QueryNsLcmOpOcc
-from lcm.ns.serializers.sol.ns_lcm_op_occs import NSLCMOpOccsSerializer
-from lcm.ns.serializers.sol.response import ProblemDetailsSerializer
+from lcm.ns.serializers.sol.ns_lcm_op_occ import NSLCMOpOccsSerializer
+from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer
 from lcm.pub.exceptions import NSLCMException
 
 logger = logging.getLogger(__name__)
index 60683ec..310ff09 100644 (file)
 # limitations under the License.
 
 import logging
+import traceback
 
 from drf_yasg.utils import swagger_auto_schema
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
 
-from lcm.ns.serializers.sol.create_ns_serializers import CreateNsRequestSerializer, CreateNsRespSerializer
-from lcm.ns.serializers.sol.pub_serializers import QueryNsRespSerializer
+from lcm.ns.serializers.sol.create_ns_serializers import CreateNsRequestSerializer
+from lcm.ns.serializers.sol.ns_instance import NsInstanceSerializer
+from lcm.pub.exceptions import BadRequestException, NSLCMException
+from lcm.pub.utils.values import ignore_case_get
+from lcm.ns.biz.ns_create import CreateNSService
+from lcm.ns.biz.ns_get import GetNSInfoService
 
 logger = logging.getLogger(__name__)
 
@@ -29,30 +34,79 @@ class NSInstancesView(APIView):
     @swagger_auto_schema(
         request_body=None,
         responses={
-            status.HTTP_200_OK: QueryNsRespSerializer(help_text="NS instances", many=True),
+            status.HTTP_200_OK: NsInstanceSerializer(help_text="NS instances", many=True),
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
         }
     )
     def get(self, request):
         logger.debug(request.query_params)
-        # todo
+        try:
+            logger.debug("CreateNSView::get")
+            ret = GetNSInfoService().get_ns_info()  # todo
+            logger.debug("CreateNSView::get::ret=%s", ret)
+            resp_serializer = NsInstanceSerializer(data=ret, many=True)
+            if not resp_serializer.is_valid():
+                raise NSLCMException(resp_serializer.errors)
+            return Response(data=resp_serializer.data, status=status.HTTP_200_OK)
+        except Exception as e:
+            logger.error(traceback.format_exc())
+            logger.error("Exception in GetNS: %s", e.message)
+            return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
     @swagger_auto_schema(
         request_body=CreateNsRequestSerializer(),
         responses={
-            status.HTTP_201_CREATED: CreateNsRespSerializer(),
+            status.HTTP_201_CREATED: NsInstanceSerializer(),
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
         }
     )
     def post(self, request):
-        logger.debug("Enter NSInstancesView::POST ns_instances %s", request.data)
-        # todo
-        return Response(data={}, status=status.HTTP_201_CREATED)
+        logger.debug("Enter NSInstancesView::POST ns_instances: Header:%s, Body: %s" % (request.META, request.data))
+        try:
+            globalCustomerId = request.META.get("HTTP_GLOBALCUSTOMERID ", None)
+            if not globalCustomerId:
+                raise BadRequestException("Not found globalCustomerId in header")
+            req_serializer = CreateNsRequestSerializer(data=request.data)
+            if not req_serializer.is_valid():
+                raise BadRequestException(req_serializer.errors)
+
+            if ignore_case_get(request.data, 'test') == "test":
+                return Response(data={'nsInstanceId': "test"}, status=status.HTTP_201_CREATED)
+            csar_id = ignore_case_get(request.data, 'nsdId')
+            ns_name = ignore_case_get(request.data, 'nsName')
+            description = ignore_case_get(request.data, 'description')
+            context = {
+                "globalCustomerId": globalCustomerId,
+                "serviceType": "NetworkService"
+            }
+            ns_inst_id = CreateNSService(csar_id, ns_name, description, context).do_biz()
+            logger.debug("CreateNSView::post::ret={'nsInstanceId':%s}", ns_inst_id)
+            ns_filter = {"ns_inst_id": ns_inst_id}
+            nsInstance = GetNSInfoService(ns_filter).get_ns_info()[0]  # todo
+            resp_serializer = NsInstanceSerializer(data=nsInstance)
+            if not resp_serializer.is_valid():
+                raise NSLCMException(resp_serializer.errors)
+            return Response(data=resp_serializer.data, status=status.HTTP_201_CREATED)
+        except BadRequestException as e:
+            logger.error("Exception in CreateNS: %s", e.message)
+            data = {'status': status.HTTP_400_BAD_REQUEST, 'detail': e.message}
+            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
+        except Exception as e:
+            logger.error("Exception in CreateNS: %s", e.message)
+            data = {'status': status.HTTP_500_INTERNAL_SERVER_ERROR, 'detail': e.message}
+            return Response(data=data, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
 
 class IndividualNsInstanceView(APIView):
-    def get(self, request, id):
-        logger.debug("Enter IndividualNsInstanceView::get ns(%s)", id)
+    @swagger_auto_schema(
+        request_body=None,
+        responses={
+            status.HTTP_200_OK: NsInstanceSerializer(help_text="NS instances", many=True),
+            status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
+        }
+    )
+    def get(self, request, ns_instance_id):
+        logger.debug("Enter IndividualNsInstanceView::get ns(%s)", ns_instance_id)
         # todo
         return Response(data={}, status=status.HTTP_200_OK)
 
@@ -62,7 +116,7 @@ class IndividualNsInstanceView(APIView):
             status.HTTP_204_NO_CONTENT: None
         }
     )
-    def delete(self, request, id):
-        logger.debug("Enter IndividualNsInstanceView::DELETE ns_instance(%s)", id)
+    def delete(self, request, ns_instance_id):
+        logger.debug("Enter IndividualNsInstanceView::DELETE ns_instance(%s)", ns_instance_id)
         # todo
         return Response(data={}, status=status.HTTP_204_NO_CONTENT)
index 3a7e831..717d6e9 100644 (file)
@@ -20,7 +20,7 @@ from rest_framework.response import Response
 from rest_framework.views import APIView
 
 from lcm.ns.biz.ns_manual_scale import NSManualScaleService
-from lcm.ns.serializers.sol.pub_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.deprecated.ns_serializers import _NsOperateJobSerializer
 from lcm.ns.serializers.sol.scale_ns_serializers import ManualScaleNsReqSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
@@ -32,7 +32,7 @@ class NSManualScaleView(APIView):
     @swagger_auto_schema(
         request_body=ManualScaleNsReqSerializer(help_text="NS manual scale"),
         responses={
-            status.HTTP_202_ACCEPTED: NsOperateJobSerializer(),
+            status.HTTP_202_ACCEPTED: _NsOperateJobSerializer(),
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
         }
     )
@@ -46,7 +46,7 @@ class NSManualScaleView(APIView):
 
             NSManualScaleService(ns_instance_id, request.data, job_id).start()
 
-            resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
+            resp_serializer = _NsOperateJobSerializer(data={'jobId': job_id})
             if not resp_serializer.is_valid():
                 raise NSLCMException(resp_serializer.errors)
 
index e66855b..ae77ed0 100644 (file)
@@ -19,7 +19,7 @@ import traceback
 
 from drf_yasg.utils import swagger_auto_schema
 from lcm.ns.serializers.sol.lccn_subscription import LccnSubscriptionSerializer
-from lcm.ns.serializers.sol.lccn_subscriptions import LccnSubscriptionsSerializer
+from lcm.ns.serializers.sol.lccn_subscription import LccnSubscriptionsSerializer
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
@@ -27,7 +27,7 @@ from rest_framework.views import APIView
 from lcm.ns.biz.create_subscription import CreateSubscription
 from lcm.ns.biz.query_subscription import QuerySubscription
 from lcm.ns.serializers.sol.lccn_subscription_request import LccnSubscriptionRequestSerializer
-from lcm.ns.serializers.sol.response import ProblemDetailsSerializer
+from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer
 from lcm.pub.exceptions import NSLCMException
 
 logger = logging.getLogger(__name__)
index d6eed05..c387bd4 100644 (file)
@@ -19,6 +19,6 @@ logger = logging.getLogger(__name__)
 
 
 class TerminateNsView(APIView):
-    def post(self, request, id):
+    def post(self, request, ns_instance_id):
         # todo
         return
index 19a03c8..12bcf6a 100644 (file)
@@ -20,7 +20,7 @@ from rest_framework.response import Response
 from rest_framework.views import APIView
 
 from lcm.ns.biz.ns_update import NSUpdateService
-from lcm.ns.serializers.sol.pub_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.deprecated.ns_serializers import _NsOperateJobSerializer
 from lcm.ns.serializers.sol.update_serializers import UpdateNsReqSerializer
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
@@ -32,7 +32,7 @@ class NSUpdateView(APIView):
     @swagger_auto_schema(
         request_body=UpdateNsReqSerializer(),
         responses={
-            status.HTTP_202_ACCEPTED: NsOperateJobSerializer(),
+            status.HTTP_202_ACCEPTED: _NsOperateJobSerializer(),
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
         }
     )
@@ -46,7 +46,7 @@ class NSUpdateView(APIView):
             job_id = JobUtil.create_job("NS", JOB_TYPE.UPDATE_NS, ns_instance_id)
             NSUpdateService(ns_instance_id, request.data, job_id).start()
 
-            resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
+            resp_serializer = _NsOperateJobSerializer(data={'jobId': job_id})
             if not resp_serializer.is_valid():
                 raise NSLCMException(resp_serializer.errors)
 
index fcc81ff..98e5039 100644 (file)
 from rest_framework import serializers
 
 from lcm.ns.serializers.sol.ext_virtual_link_info import ExtVirtualLinkInfoSerializer
-from lcm.ns.serializers.sol.link import linkSerializer
-from lcm.ns.serializers.sol.pub_serializers import AddressRangeSerializer
+from lcm.ns.serializers.sol.cp_serializers import AddressRangeSerializer
 from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
-from lcm.ns.serializers.sol.response import ProblemDetailsSerializer
+from lcm.ns.serializers.sol.pub_serializers import ProblemDetailsSerializer, LinkSerializer
 
 
 # class ResourceHandleSerializer(serializers.Serializer):
@@ -137,11 +136,11 @@ class VimConstraintSerializer(serializers.Serializer):
 
 
 class GrantRequestLinksSerializer(serializers.Serializer):
-    vnfLcmOpOcc = linkSerializer(
+    vnfLcmOpOcc = LinkSerializer(
         help_text="Related VNF lifecycle management operation occurrence.",
         required=True
     )
-    vnfInstance = linkSerializer(
+    vnfInstance = LinkSerializer(
         help_text="Related VNF instance.",
         required=True
     )
@@ -573,15 +572,15 @@ class ExtManagedVirtualLinkSerializer(serializers.Serializer):
 
 
 class GrantLinksSerializer(serializers.Serializer):
-    self = linkSerializer(
+    self = LinkSerializer(
         help_text="URI of this resource.",
         required=True
     )
-    vnfLcmOpOcc = linkSerializer(
+    vnfLcmOpOcc = LinkSerializer(
         help_text="Related VNF lifecycle management operation occurrence.",
         required=True
     )
-    vnfInstance = linkSerializer(
+    vnfInstance = LinkSerializer(
         help_text="Related VNF instance.",
         required=True
     )
@@ -918,15 +917,15 @@ class ExtLinkPortInfoSerializer(serializers.Serializer):
 
 
 class LccnLinksSerializer(serializers.Serializer):
-    vnfInstance = linkSerializer(
+    vnfInstance = LinkSerializer(
         help_text="Link to the resource representing the VNF instance to which the notified change applies.",
         required=True
     )
-    subscription = linkSerializer(
+    subscription = LinkSerializer(
         help_text="Link to the related subscription.",
         required=True
     )
-    vnfLcmOpOcc = linkSerializer(
+    vnfLcmOpOcc = LinkSerializer(
         help_text="Link to the VNF lifecycle management operation occurrence that this notification is related to.",
         required=False,
         allow_null=True
index 2c3f2ca..6dd5dcb 100644 (file)
@@ -15,3 +15,7 @@
 
 class NSLCMException(Exception):
     pass
+
+
+class BadRequestException(Exception):
+    pass
index 09b9a5d..f20f363 100644 (file)
@@ -115,6 +115,12 @@ DATABASES = {
     },
 }
 
+# DATABASES = {}
+# DATABASES['default'] = {
+#    'ENGINE': 'django.db.backends.sqlite3',
+#    'NAME': 'D:/etsi-plug-test/db/nfvo',
+# }
+
 redisco.connection_setup(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=0)
 # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' % (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)