1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rest_framework import serializers
18 class AddressRangeSerializer(serializers.Serializer):
19 minAddress = serializers.IPAddressField(help_text="Lowest IP address belonging to the range.",
21 maxAddress = serializers.IPAddressField(help_text="Highest IP address belonging to the range.",
25 class IpAddressesDataSerialzier(serializers.Serializer):
26 type = serializers.ChoiceField(help_text="The type of the IP addresses.",
27 required=True, choices=["IPV4", "IPV6"])
28 fixedAddresses = serializers.ListField(child=serializers.CharField(help_text="Fixed addresses to assign.",
29 required=False, allow_null=True))
30 numDynamicAddresses = serializers.IntegerField(help_text="Number of dynamic addresses to assign.",
32 addressRange = AddressRangeSerializer(help_text="An IP address range to be used.", required=False)
33 subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet resource"
34 " in the VIM.", required=False, allow_null=True,
38 class IpAddressesInfoSerialzier(serializers.Serializer):
39 type = serializers.ChoiceField(help_text="The type of the IP addresses.",
40 required=True, choices=["IPV4", "IPV6"])
41 addresses = serializers.ListField(help_text="An IPV4 or IPV6 address", required=False, allow_null=True)
42 isDynamic = serializers.BooleanField(help_text="Indicates whether this set of addresses was assigned"
43 " dynamically (true) or based on address information"
44 " provided as input from the API consumer (false). ",
46 addressRange = AddressRangeSerializer(help_text="An IP address range used,",
47 required=False, allow_null=True)
48 subnetId = serializers.CharField(help_text="Subnet defined by the identifier of the subnet resource in "
49 "the VIM. ", required=False, allow_null=True)
52 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
53 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
54 ipAddresses = IpAddressesDataSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
55 required=False, allow_null=True, many=True)
58 class IpOverEthernetAddressInfoSerializer(serializers.Serializer):
59 macAddress = serializers.CharField(help_text="Mac address", required=False, allow_null=True)
60 ipAddresses = IpAddressesInfoSerialzier(help_text="List of IP addresses to assign to the extCP instance.",
61 required=False, allow_null=True, many=True)
64 class CpProtocolDataSerializer(serializers.Serializer):
65 layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
66 choices=["IP_OVER_ETHERNET"], required=True)
67 ipOverEthernet = IpOverEthernetAddressDataSerializer(help_text="Network address data for IP over Ethernet"
68 "to assign to the extCP instance.",
69 required=False, allow_null=True)
72 class CpProtocolInfoSerializer(serializers.Serializer):
73 layerProtocol = serializers.ChoiceField(help_text="Identifier of layer(s) and protocol(s)",
74 choices=["IP_OVER_ETHERNET"], required=True)
75 ipOverEthernet = IpOverEthernetAddressInfoSerializer(help_text="Network address data for IP over Ethernet"
76 "to assign to the extCP instance.",
77 required=False, allow_null=True)
80 class VnfExtCpInfoSerializer(serializers.Serializer):
81 id = serializers.CharField(
82 help_text="Identifier of the external CP instance and the related information instance.",
87 cpdId = serializers.CharField(
88 help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.",
93 cpProtocolInfo = CpProtocolInfoSerializer(
94 help_text="Network protocol information for this CP.",
98 extLinkPortId = serializers.CharField(
99 help_text="Identifier of the extLinkPortInfo structure inside the extVirtualLinkInfo structure.",