fix cp related error 45/83845/1
authormaopengzhang <zhang.maopeng1@zte.com.cn>
Mon, 1 Apr 2019 09:12:17 +0000 (17:12 +0800)
committermaopengzhang <zhang.maopeng1@zte.com.cn>
Mon, 1 Apr 2019 09:13:06 +0000 (17:13 +0800)
fix cp related error

Change-Id: I2d3362bdc1d416e1b5c9dc91be716f5870114539
Issue-ID: VFC-1213
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
lcm/ns/const.py
lcm/ns/serializers/sol/cp_serializers.py

index 7fd0fc9..53f4930 100644 (file)
@@ -101,6 +101,10 @@ CHANGE_RESULTS = enum(
     PARTIALLY_COMPLETED='PARTIALLY_COMPLETED'
 )
 
+IPADDRESSES_TYPES = enum(
+    IPV4='IPV4',
+    IPV6='IPV6'
+)
 
 ROOT_URI = "api/nslcm/v1/subscriptions/"
 
@@ -168,5 +172,6 @@ CHANGE_RESULT = [
     CHANGE_RESULTS.FAILED
 ]
 
+
 NS_INSTANCE_BASE_URI = MSB_BASE_URL + '/api/nslcm/v1/ns_instances/%s'
 NS_OCC_BASE_URI = MSB_BASE_URL + '/api/nslcm/v1/ns_lcm_op_occs/%s'
index 8e541ae..c15166d 100644 (file)
 # limitations under the License.
 
 from rest_framework import serializers
+from lcm.ns.const import IPADDRESSES_TYPES
+
+IPADDRESSES_TYPE = [
+    IPADDRESSES_TYPES.IPV4,
+    IPADDRESSES_TYPES.IPV6
+]
+LAYER_PROTOCOL = [
+    "IP_OVER_ETHERNET"
+]
 
 
 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)
+    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)
+    type = serializers.ChoiceField(
+        help_text="The type of the IP addresses.",
+        required=True,
+        choices=IPADDRESSES_TYPE)
+    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)
+    type = serializers.ChoiceField(
+        help_text="The type of the IP addresses.",
+        required=True,
+        choices=IPADDRESSES_TYPE)
+    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)
+    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)
+    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)
+    layerProtocol = serializers.ChoiceField(
+        help_text="Identifier of layer(s) and protocol(s)",
+        choices=LAYER_PROTOCOL,
+        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)
+    layerProtocol = serializers.ChoiceField(
+        help_text="Identifier of layer(s) and protocol(s)",
+        choices=LAYER_PROTOCOL,
+        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):