seperate sol and deprecated serializers
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / cp_serializers.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2
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
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
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.
14
15 from rest_framework import serializers
16
17
18 class AddressRangeSerializer(serializers.Serializer):
19     minAddress = serializers.IPAddressField(help_text="Lowest IP address belonging to the range.",
20                                             required=True)
21     maxAddress = serializers.IPAddressField(help_text="Highest IP address belonging to the range.",
22                                             required=True)
23
24
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.",
31                                                    required=False)
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,
35                                      allow_blank=True)
36
37
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). ",
45                                          required=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)
50
51
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)
56
57
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)
62
63
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)
70
71
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)
78
79
80 class VnfExtCpInfoSerializer(serializers.Serializer):
81     id = serializers.CharField(
82         help_text="Identifier of the external CP instance and the related information instance.",
83         max_length=255,
84         required=True,
85         allow_null=True,
86         allow_blank=False)
87     cpdId = serializers.CharField(
88         help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.",
89         max_length=255,
90         required=True,
91         allow_null=True,
92         allow_blank=False)
93     cpProtocolInfo = CpProtocolInfoSerializer(
94         help_text="Network protocol information for this CP.",
95         many=True,
96         required=False,
97         allow_null=True)
98     extLinkPortId = serializers.CharField(
99         help_text="Identifier of the extLinkPortInfo structure inside the extVirtualLinkInfo structure.",
100         max_length=255,
101         required=False,
102         allow_null=True,
103         allow_blank=True)