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
16 from lcm.ns.const import IPADDRESSES_TYPE_LIST
24 class AddressRangeSerializer(serializers.Serializer):
25 minAddress = serializers.IPAddressField(
26 help_text="Lowest IP address belonging to the range.",
28 maxAddress = serializers.IPAddressField(
29 help_text="Highest IP address belonging to the range.",
33 class IpAddressesDataSerialzier(serializers.Serializer):
34 type = serializers.ChoiceField(
35 help_text="The type of the IP addresses.",
37 choices=IPADDRESSES_TYPE_LIST)
38 fixedAddresses = serializers.ListField(
39 child=serializers.CharField(
40 help_text="Fixed addresses to assign.",
43 numDynamicAddresses = serializers.IntegerField(
44 help_text="Number of dynamic addresses to assign.",
46 addressRange = AddressRangeSerializer(
47 help_text="An IP address range to be used.",
49 subnetId = serializers.CharField(
50 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
56 class IpAddressesInfoSerialzier(serializers.Serializer):
57 type = serializers.ChoiceField(
58 help_text="The type of the IP addresses.",
60 choices=IPADDRESSES_TYPE_LIST)
61 addresses = serializers.ListField(
62 help_text="An IPV4 or IPV6 address",
65 isDynamic = serializers.BooleanField(
66 help_text="Indicates whether this set of addresses was assigned"
67 " dynamically (true) or based on address information"
68 " provided as input from the API consumer (false).",
70 addressRange = AddressRangeSerializer(
71 help_text="An IP address range used,",
74 subnetId = serializers.CharField(
75 help_text="Subnet defined by the identifier of the subnet resource in the VIM.",
80 class IpOverEthernetAddressDataSerializer(serializers.Serializer):
81 macAddress = serializers.CharField(
82 help_text="Mac address",
85 ipAddresses = IpAddressesDataSerialzier(
86 help_text="List of IP addresses to assign to the extCP instance.",
92 class IpOverEthernetAddressInfoSerializer(serializers.Serializer):
93 macAddress = serializers.CharField(
94 help_text="Mac address",
97 ipAddresses = IpAddressesInfoSerialzier(
98 help_text="List of IP addresses to assign to the extCP instance.",
104 class CpProtocolDataSerializer(serializers.Serializer):
105 layerProtocol = serializers.ChoiceField(
106 help_text="Identifier of layer(s) and protocol(s)",
107 choices=LAYER_PROTOCOL,
109 ipOverEthernet = IpOverEthernetAddressDataSerializer(
110 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
115 class CpProtocolInfoSerializer(serializers.Serializer):
116 layerProtocol = serializers.ChoiceField(
117 help_text="Identifier of layer(s) and protocol(s)",
118 choices=LAYER_PROTOCOL,
120 ipOverEthernet = IpOverEthernetAddressInfoSerializer(
121 help_text="Network address data for IP over Ethernet to assign to the extCP instance.",
126 class VnfExtCpInfoSerializer(serializers.Serializer):
127 id = serializers.CharField(
128 help_text="Identifier of the external CP instance and the related information instance.",
133 cpdId = serializers.CharField(
134 help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.",
139 cpProtocolInfo = CpProtocolInfoSerializer(
140 help_text="Network protocol information for this CP.",
144 extLinkPortId = serializers.CharField(
145 help_text="Identifier of the extLinkPortInfo structure inside the extVirtualLinkInfo structure.",