Add vfc-vnflcm extCp schema
[vfc/gvnfm/vnflcm.git] / lcm / lcm / v2 / serializers.py
1 # Copyright 2018 ZTE Corporation.
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 from rest_framework import serializers
15
16
17 class VimInfoSerializer(serializers.Serializer):
18     id = serializers.CharField(
19         help_text="The identifier of the VIM Connection. This identifier is managed by the NFVO.",
20         required=False,
21         max_length=255,
22         allow_null=True)
23     vimId = serializers.CharField(
24         help_text="The identifier of the VIM instance. This identifier is managed by the NFVO.",
25         required=False,
26         max_length=255,
27         allow_null=True)
28     vimType = serializers.CharField(
29         help_text="Discriminator for the different types of the VIM information.",
30         required=False,
31         max_length=255,
32         allow_null=True)
33     interfaceInfo = serializers.DictField(
34         help_text="Information about the interface or interfaces to the VIM",
35         child=serializers.CharField(allow_blank=True),
36         required=False,
37         allow_null=True)
38     accessInfo = serializers.DictField(
39         help_text="Authentication credentials for accessing the VIM, and other access-related information",
40         child=serializers.CharField(allow_blank=True),
41         required=False,
42         allow_null=True)
43     extra = serializers.DictField(
44         help_text="VIM type specific additional information.",
45         child=serializers.CharField(allow_blank=True),
46         required=False,
47         allow_null=True)
48
49
50 class ScaleInfoSerializer(serializers.Serializer):
51     aspectId = serializers.CharField(
52         help_text="Identifier of the scaling aspect.",
53         required=True,
54         max_length=255,
55         allow_null=True)
56     scaleLevel = serializers.IntegerField(
57         help_text="Indicates the scale level.",
58         required=True)
59
60
61 class CpProtocolInfoSerializer(serializers.Serializer):
62     layerProtocol = serializers.ChoiceField(
63         help_text="The identifier of layer(s) and protocol(s) associated to the network address information.",
64         choices=["IP_OVER_ETHERNET"],
65         required=False,
66         allow_null=True)
67     ipOverEthernet = serializers.DictField(
68         help_text="IP addresses over Ethernet to assign to the extCP instance.",
69         child=serializers.CharField(allow_blank=True),
70         required=False,
71         allow_null=True)
72
73
74 class ExtCpInfoSerializer(serializers.Serializer):
75     id = serializers.CharField(
76         help_text="Identifier of the external CP instance and the related information instance.",
77         required=False,
78         max_length=255,
79         allow_null=True)
80     cpdId = serializers.CharField(
81         help_text="Identifier of the external CPD, VnfExtCpd, in the VNFD.",
82         required=True,
83         max_length=255,
84         allow_null=True)
85     cpProtocolInfo = CpProtocolInfoSerializer(
86         help_text="Network protocol information for this CP.",
87         required=False,
88         allow_null=True)
89     extLinkPortId = serializers.CharField(
90         help_text="Identifier of the 'extLinkPortInfo' structure inside the 'extVirtualLinkInfo' structure.",
91         required=False,
92         max_length=255,
93         allow_null=True)
94
95
96 class instantiatedVnfInfoSerializer(serializers.Serializer):
97     flavourId = serializers.CharField(
98         help_text="Identifier of the VNF deployment flavour applied to this VNF instance.",
99         required=True,
100         max_length=255,
101         allow_null=True)
102     vnfState = serializers.ChoiceField(
103         help_text="State of the VNF instance.",
104         choices=["STARTED", "STOPPED"],
105         required=True,
106         allow_null=True)
107     scaleStatus = ScaleInfoSerializer(
108         help_text="Scale status of the VNF, one entry per aspect.",
109         required=False,
110         many=True)
111     extCpInfo = ExtCpInfoSerializer(
112         help_text="Information about the external CPs exposed by the VNF instance.",
113         required=False,
114         many=True)
115
116
117 class VnfInstanceSerializer(serializers.Serializer):
118     id = serializers.CharField(
119         help_text="Identifier of the VNF instance",
120         required=True)
121     vnfInstanceName = serializers.CharField(
122         help_text="Name of the VNF instance.",
123         required=False,
124         allow_null=True,
125         allow_blank=True)
126     vnfInstanceDescription = serializers.CharField(
127         help_text="Human-readable description of the VNF instance.",
128         required=False,
129         allow_null=True,
130         allow_blank=True)
131     vnfdId = serializers.CharField(
132         help_text="Identifier of the VNFD on which the VNF instance is based.",
133         required=False,
134         allow_null=True,
135         allow_blank=True)
136     vnfProvider = serializers.CharField(
137         help_text="Provider of the VNF and the VNFD. The value is copied from the VNFD.",
138         required=False,
139         allow_null=True,
140         allow_blank=True)
141     vnfProductName = serializers.CharField(
142         help_text="Name to identify the VNF Product. The value is copied from the VNFD.",
143         required=False,
144         allow_null=True,
145         allow_blank=True)
146     vnfSoftwareVersion = serializers.CharField(
147         help_text="Software version of the VNF. The value is copied from the VNFD.",
148         required=False,
149         allow_null=True,
150         allow_blank=True)
151     vnfdVersion = serializers.CharField(
152         help_text="Identifies the version of the VNFD. The value is copied from the VNFD.",
153         required=False,
154         allow_null=True,
155         allow_blank=True)
156     vnfPkgId = serializers.CharField(
157         help_text="Identifier of information held by the NFVO about the specific VNF package on which the VNF is based.",
158         required=False,
159         allow_null=True,
160         allow_blank=True)
161     vnfConfigurableProperties = serializers.DictField(
162         help_text="Current values of the configurable properties of the VNF instance.",
163         child=serializers.CharField(allow_blank=True),
164         required=False,
165         allow_null=True)
166     vimConnectionInfo = VimInfoSerializer(
167         help_text="Information about VIM connections to be used for managing the resources for the VNF instance.",
168         required=False,
169         allow_null=True)
170     instantiationState = serializers.ChoiceField(
171         help_text="The instantiation state of the VNF.",
172         choices=["NOT_INSTANTIATED", "INSTANTIATED"],
173         required=False,
174         allow_null=True)
175     instantiatedVnfInfo = instantiatedVnfInfoSerializer(
176         help_text="Information specific to an instantiated VNF instance.",
177         required=False)