Optimize ns instant.
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / ext_managed_virtual_link_info.py
1 # Copyright 2019 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
15 from rest_framework import serializers
16 from lcm.ns.serializers.sol.resource_handle import ResourceHandleSerializer
17 from lcm.ns.enum import CP_INSTANCE_TYPE
18 from lcm.pub.utils.enumutil import enum_to_list
19
20
21 class VnfLinkPortInfo(serializers.Serializer):
22     id = serializers.CharField(
23         help_text="Identifier of this link port as provided by the entity that has created the link port.",
24         max_length=255,
25         required=True,
26         allow_null=False,
27         allow_blank=False)
28     resourceHandle = ResourceHandleSerializer(
29         help_text="Reference to the virtualised network resource realizing this link port.",
30         required=True,
31         allow_null=False)
32     cpInstanceId = serializers.CharField(
33         help_text="When the link port is used for external connectivity by the VNF, \
34         this attribute represents the identifier of the external CP of the VNF to be connected to this \
35         link port.",
36         max_length=255,
37         required=False,
38         allow_null=True,
39         allow_blank=True)
40     cpInstanceType = serializers.ChoiceField(
41         required=False,
42         choices=enum_to_list(CP_INSTANCE_TYPE),
43         help_text="Type of the CP instance that is identified by cpInstanceId.")
44
45
46 class ExtManagedVirtualLinkInfo(serializers.Serializer):
47     id = serializers.CharField(
48         help_text="Identifier of the externally-managed inner VL and the related externally-managed VL information instance.",
49         max_length=255,
50         required=True)
51     vnfVirtualLinkDescId = serializers.CharField(
52         help_text="Identifier of the VNF Virtual Link Descriptor (VLD) in the VNFD.",
53         max_length=255,
54         required=True)
55     networkResource = ResourceHandleSerializer(
56         help_text="ResourceHandle,reference to the VirtualNetwork resource.",
57         required=True,
58         allow_null=False)
59     vnfLinkPorts = VnfLinkPortInfo(
60         help_text="VnfLinkPortInfo, Link ports of this VL.",
61         many=True,
62         required=False)