diff options
author | tianxing <15210838572@139.com> | 2019-01-08 16:34:20 +0800 |
---|---|---|
committer | tianxing <15210838572@139.com> | 2019-01-08 16:34:29 +0800 |
commit | 5d5dc2adf8181c4ae222d1d3a8c3fa310c4de527 (patch) | |
tree | 62e9aa9c6f6109ff646b3af4ea4ef99bc951627a | |
parent | 1a8e0a58a85f4925879dc1535710424a09bbb42e (diff) |
separate ns-heal
Change-Id: I29830708d28cae7b4a46c75c81d625505c9d60cd
Signed-off-by: tianxing <15210838572@139.com>
Issue-ID: VFC-1230
-rw-r--r-- | lcm/ns/serializers/heal_serializers.py | 23 | ||||
-rw-r--r-- | lcm/ns/serializers/ns_serializers.py | 32 | ||||
-rw-r--r-- | lcm/ns/tests/test_ns_heal.py | 12 | ||||
-rw-r--r-- | lcm/ns/views/heal_ns_view.py | 2 |
4 files changed, 22 insertions, 47 deletions
diff --git a/lcm/ns/serializers/heal_serializers.py b/lcm/ns/serializers/heal_serializers.py index a8d43e4d..a935fded 100644 --- a/lcm/ns/serializers/heal_serializers.py +++ b/lcm/ns/serializers/heal_serializers.py @@ -15,15 +15,25 @@ from rest_framework import serializers +class ActionVmSerializer(serializers.Serializer): + vmid = serializers.CharField(help_text="ID of VM", required=False, allow_null=True, allow_blank=True) + vduid = serializers.CharField(help_text="ID of vdu", required=False, allow_null=True, allow_blank=True) + vmname = serializers.CharField(help_text="Name of VM", required=False, allow_null=True, allow_blank=True) + + +class HealNsAdditionalParamsSerializer(serializers.Serializer): + action = serializers.CharField(help_text="Action of NS heal", required=False, allow_null=True, allow_blank=True) + actionvminfo = ActionVmSerializer(help_text="VM info of action", required=False, allow_null=True) + + class HealVnfDataSerializer(serializers.Serializer): vnfInstanceId = serializers.CharField(help_text="Identifies the VNF instance,", required=True) cause = serializers.CharField(help_text="Indicates the reason why a healing procedure is required", required=False, allow_null=True, allow_blank=True) additionalParams = serializers.DictField(help_text="Additional parameters passed by the NFVO as input to " "the healing process", - child=serializers.CharField(help_text="KeyValue Pairs", - allow_blank=True), - required=False, allow_null=True) + child=HealNsAdditionalParamsSerializer( + help_text="KeyValue Pairs"), required=False, allow_null=True) class HealNsDataSerializer(serializers.Serializer): @@ -37,10 +47,7 @@ class HealNsDataSerializer(serializers.Serializer): class HealNsReqSerializer(serializers.Serializer): - healVnfData = serializers.ListField(help_text="Provides the information needed to heal a VNF. ", - child=HealVnfDataSerializer( - help_text="This type represents the information to heal a VNF" - "that is part of an NS", required=True), - required=False, allow_null=True) + healVnfData = HealVnfDataSerializer(help_text="Data of heal VNF", required=False, allow_null=True, + many=True) healNsData = HealNsDataSerializer(help_text="Provides the information needed to heal an NS", required=False, allow_null=True) diff --git a/lcm/ns/serializers/ns_serializers.py b/lcm/ns/serializers/ns_serializers.py index faeda6ce..2e44b696 100644 --- a/lcm/ns/serializers/ns_serializers.py +++ b/lcm/ns/serializers/ns_serializers.py @@ -145,38 +145,6 @@ class TerminateNsReqSerializer(serializers.Serializer): gracefulTerminationTimeout = serializers.CharField(help_text="Timeout of NS graceful termination", required=False, allow_null=True, allow_blank=True) -class ActionVmSerializer(serializers.Serializer): - vmid = serializers.CharField(help_text="ID of VM", required=False, allow_null=True, allow_blank=True) - vduid = serializers.CharField(help_text="ID of vdu", required=False, allow_null=True, allow_blank=True) - vmname = serializers.CharField(help_text="Name of VM", required=False, allow_null=True, allow_blank=True) - - -class HealNsAdditionalParamsSerializer(serializers.Serializer): - action = serializers.CharField(help_text="Action of NS heal", required=False, allow_null=True, allow_blank=True) - actionvminfo = ActionVmSerializer(help_text="VM info of action", required=False, allow_null=True) - - -class HealVnfDataSerializer(serializers.Serializer): - vnfInstanceId = serializers.CharField(help_text="ID of VNF Instance", required=True) - cause = serializers.CharField(help_text="Cause of NS heal", required=False, allow_null=True, allow_blank=True) - additionalParams = HealNsAdditionalParamsSerializer(help_text="Additional params of NS heal", required=False, allow_null=True) - - -class HealNsDataSerializer(serializers.Serializer): - degreeHealing = serializers.ChoiceField(help_text="degree of healing", choices=["HEAL_RESTORE", "HEAL_QOS", "HEAL_RESET", "PARTIAL_HEALING"], required=True) - actionsHealing = serializers.ListField( - help_text="A list of actions", - child=serializers.CharField(help_text="One action", required=True), - required=False) - healScript = serializers.CharField(help_text="script of NS heal", required=False, allow_null=True, allow_blank=True) - additionalParamsforNs = serializers.CharField(help_text="Addition params of NS heal", required=False, allow_null=True, allow_blank=True) - - -class HealNsReqSerializer(serializers.Serializer): - healVnfData = HealVnfDataSerializer(help_text="Data of heal VNF", required=False, allow_null=True) - healNsData = HealNsDataSerializer(help_text="Data of heal NS", required=False, allow_null=True) - - class InstNsPostDealReqSerializer(serializers.Serializer): status = serializers.CharField(help_text="Status of NS Inst", required=True) diff --git a/lcm/ns/tests/test_ns_heal.py b/lcm/ns/tests/test_ns_heal.py index 0707ebe1..c4fbf983 100644 --- a/lcm/ns/tests/test_ns_heal.py +++ b/lcm/ns/tests/test_ns_heal.py @@ -77,7 +77,7 @@ class TestHealNsViews(TestCase): def test_heal_vnf_url(self, mock_run): data = { - "healVnfData": { + "healVnfData": [{ "vnfInstanceId": self.nf_inst_id, "cause": "vm is down", "additionalParams": { @@ -88,7 +88,7 @@ class TestHealNsViews(TestCase): "vmname": "xgw-smp11" } } - } + }] } response = self.client.post("/api/nslcm/v1/ns/%s/heal" % self.ns_inst_id, data=data) @@ -134,7 +134,7 @@ class TestHealNsViews(TestCase): def test_heal_vnf_thread(self, mock_start, mock_wait, mock_update): data = { - "healVnfData": { + "healVnfData": [{ "vnfInstanceId": self.nf_inst_id, "cause": "vm is down", "additionalParams": { @@ -145,7 +145,7 @@ class TestHealNsViews(TestCase): "vmname": "xgw-smp11" } } - } + }] } NSHealService(self.ns_inst_id, data, self.job_id).run() @@ -182,7 +182,7 @@ class TestHealNsViews(TestCase): ns_inst_id = "2" data = { - "healVnfData": { + "healVnfData": [{ "vnfInstanceId": self.nf_inst_id, "cause": "vm is down", "additionalParams": { @@ -192,7 +192,7 @@ class TestHealNsViews(TestCase): "vmname": "xgw-smp11" } } - } + }] } response = self.client.post("/api/nslcm/v1/ns/%s/heal" % ns_inst_id, data=data) diff --git a/lcm/ns/views/heal_ns_view.py b/lcm/ns/views/heal_ns_view.py index a0534e33..71242bce 100644 --- a/lcm/ns/views/heal_ns_view.py +++ b/lcm/ns/views/heal_ns_view.py @@ -19,7 +19,7 @@ from rest_framework.views import APIView from drf_yasg.utils import swagger_auto_schema from lcm.ns.biz.ns_heal import NSHealService -from lcm.ns.serializers.ns_serializers import HealNsReqSerializer +from lcm.ns.serializers.heal_serializers import HealNsReqSerializer from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer from lcm.pub.exceptions import NSLCMException from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE |