1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from rest_framework import serializers
18 class ActionVmSerializer(serializers.Serializer):
19 vmid = serializers.CharField(help_text="ID of VM", required=False, allow_null=True, allow_blank=True)
20 vduid = serializers.CharField(help_text="ID of vdu", required=False, allow_null=True, allow_blank=True)
21 vmname = serializers.CharField(help_text="Name of VM", required=False, allow_null=True, allow_blank=True)
24 class HealNsAdditionalParamsSerializer(serializers.Serializer):
25 action = serializers.CharField(help_text="Action of NS heal", required=False, allow_null=True, allow_blank=True)
26 actionvminfo = ActionVmSerializer(help_text="VM info of action", required=False, allow_null=True)
29 class HealVnfDataSerializer(serializers.Serializer):
30 vnfInstanceId = serializers.CharField(help_text="Identifies the VNF instance,", required=True)
31 cause = serializers.CharField(help_text="Indicates the reason why a healing procedure is required",
32 required=False, allow_null=True, allow_blank=True)
33 additionalParams = serializers.DictField(help_text="Additional parameters passed by the NFVO as input to "
34 "the healing process",
35 child=HealNsAdditionalParamsSerializer(
36 help_text="KeyValue Pairs"), required=False, allow_null=True)
39 class HealNsDataSerializer(serializers.Serializer):
40 degreeHealing = serializers.ChoiceField(help_text="degree of healing", choices=["HEAL_RESTORE", "HEAL_QOS", "HEAL_RESET", "PARTIAL_HEALING"], required=True)
41 actionsHealing = serializers.ListField(
42 help_text="A list of actions",
43 child=serializers.CharField(help_text="One action", required=True),
45 healScript = serializers.CharField(help_text="script of NS heal", required=False, allow_null=True, allow_blank=True)
46 additionalParamsforNs = serializers.CharField(help_text="Addition params of NS heal", required=False, allow_null=True, allow_blank=True)
49 class HealNsReqSerializer(serializers.Serializer):
50 healVnfData = HealVnfDataSerializer(help_text="Data of heal VNF", required=False, allow_null=True,
52 healNsData = HealNsDataSerializer(help_text="Provides the information needed to heal an NS",
53 required=False, allow_null=True)