c4d9a2bc04726686c56724428ba10a823d504fe9
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / affected_vnfs.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
16 from rest_framework import serializers
17
18 from lcm.ns.const import CHANGE_TYPES, CHANGE_RESULT
19 from lcm.ns.serializers.sol.ext_virtual_link_info import ExtVirtualLinkInfoSerializer
20 from lcm.ns.serializers.sol.update_serializers import ModifyVnfInfoDataSerializer
21
22 CHANGE_TYPE = [
23     CHANGE_TYPES.ADD,
24     CHANGE_TYPES.REMOVE,
25     CHANGE_TYPES.INSTANTIATE,
26     CHANGE_TYPES.TERMINATE,
27     CHANGE_TYPES.SCALE,
28     CHANGE_TYPES.CHANGE_FLAVOUR,
29     CHANGE_TYPES.HEAL,
30     CHANGE_TYPES.OPERATE,
31     CHANGE_TYPES.MODIFY_INFORMATION,
32     CHANGE_TYPES.CHANGE_EXTERNAL_VNF_CONNECTIVITY
33 ]
34
35
36 class ChangedInfoSerializer(serializers.Serializer):
37     changedVnfInfo = ModifyVnfInfoDataSerializer(
38         help_text="Information about the changed VNF instance information, including configurable properties",
39         required=False)
40     changedExtConnectivity = ExtVirtualLinkInfoSerializer(
41         help_text="Link to the task resource that represents the 'fail' Information about changed external "
42                   "connectivity, if applicable.",
43         required=False)
44
45
46 class AffectedVnfsSerializer(serializers.Serializer):
47     vnfInstanceId = serializers.UUIDField(
48         help_text="Identifier of the VNF instance.",
49         required=True
50     )
51     vnfdId = serializers.UUIDField(
52         help_text="Identifier of the VNFD of the VNF Instance..",
53         required=True
54     )
55     vnfProfileId = serializers.UUIDField(
56         help_text="Identifier of the VNF profile of the NSD.",
57         required=True
58     )
59     vnfName = serializers.CharField(
60         help_text="Name of the VNF Instance.",
61         required=True)
62     changeType = serializers.ChoiceField(
63         help_text="Signals the type of change",
64         required=True,
65         choices=CHANGE_TYPE
66     )
67     changeResult = serializers.ChoiceField(
68         help_text="Signals the type of change",
69         required=True,
70         choices=CHANGE_RESULT
71     )
72     changedInfo = ChangedInfoSerializer(
73         help_text="Links to resources related to this resource.",
74         required=False)