fix NS heal serializer error
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / heal_serializers.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2 # Copyright 2019 ZTE Corporation.
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from rest_framework import serializers
17
18
19 # class ActionVmSerializer(serializers.Serializer):
20 #    vmid = serializers.CharField(help_text="ID of VM", required=False, allow_null=True, allow_blank=True)
21 #    vduid = serializers.CharField(help_text="ID of vdu", required=False, allow_null=True, allow_blank=True)
22 #    vmname = serializers.CharField(help_text="Name of VM", required=False, allow_null=True, allow_blank=True)
23
24
25 # class HealNsAdditionalParamsSerializer(serializers.Serializer):
26 #    action = serializers.CharField(help_text="Action of NS heal", required=False, allow_null=True, allow_blank=True)
27 #    actionvminfo = ActionVmSerializer(help_text="VM info of action", required=False, allow_null=True)
28
29
30 class HealVnfDataSerializer(serializers.Serializer):
31     vnfInstanceId = serializers.CharField(
32         help_text="Identifies the VNF instance, part of the NS, requiring a healing action.",
33         required=True)
34     cause = serializers.CharField(
35         help_text="Indicates the reason why a healing procedure is required.",
36         required=False,
37         allow_null=True,
38         allow_blank=True)
39     additionalParams = serializers.DictField(
40         help_text="Additional parameters passed by the NFVO as input to the healing process, specific to the VNF being healed.",
41         required=False,
42         allow_null=True)
43
44
45 class HealNsDataSerializer(serializers.Serializer):
46     degreeHealing = serializers.ChoiceField(
47         help_text="Indicates the degree of healing.",
48         choices=["HEAL_RESTORE", "HEAL_QOS", "HEAL_RESET", "PARTIAL_HEALING"],
49         required=True)
50     actionsHealing = serializers.ListField(
51         help_text="Used to specify dedicated healing actions in a particular order",
52         child=serializers.CharField(
53             help_text="one dedicated healing action",
54             required=True),
55         required=False)
56     healScript = serializers.CharField(
57         help_text="Reference to a script from the NSD that shall be used to execute dedicated healing actions in a particular order.",
58         required=False,
59         allow_null=True,
60         allow_blank=True)
61     additionalParamsforNs = serializers.DictField(
62         help_text="Allows the OSS/BSS to provide additional parameter(s) to the healing process at the NS level.",
63         required=False)
64
65
66 class HealNsReqSerializer(serializers.Serializer):
67     healVnfData = HealVnfDataSerializer(
68         help_text="Provides the information needed to heal a VNF.",
69         required=False,
70         allow_null=True,
71         many=True)
72     healNsData = HealNsDataSerializer(
73         help_text="Provides the information needed to heal an NS.",
74         required=False,
75         allow_null=True)