From 909d60f4cc068574b058cdc2b955b90b2ce8660d Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Wed, 7 Feb 2018 09:22:09 +0800 Subject: Add vfc-ztevnfmdriver scale schema Change-Id: I5ca9ff027d6b1fce9c1f1dfe194ab1cd563bc0a1 Issue-ID: VFC-736 Signed-off-by: ying.yunlong --- zte/vmanager/driver/interfaces/serializers.py | 28 ++++++++++++++++++++++++--- zte/vmanager/driver/interfaces/tests.py | 9 ++++++--- zte/vmanager/driver/interfaces/views.py | 10 +++++----- zte/vmanager/driver/swagger/swagger.json | 4 ++-- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/zte/vmanager/driver/interfaces/serializers.py b/zte/vmanager/driver/interfaces/serializers.py index 2e601185..fbe7660d 100644 --- a/zte/vmanager/driver/interfaces/serializers.py +++ b/zte/vmanager/driver/interfaces/serializers.py @@ -15,6 +15,28 @@ from rest_framework import serializers +class ScaleReqSerializer(serializers.Serializer): + type = serializers.CharField( + help_text="type", + max_length=255, + required=True, allow_blank=True) + aspectId = serializers.CharField( + help_text="aspectId", + max_length=255, + required=True, + allow_null=False) + numberOfSteps = serializers.CharField( + help_text="numberOfSteps", + max_length=255, + required=False, + allow_null=True) + additionalParam = serializers.DictField( + help_text="additionalParam", + child=serializers.CharField(allow_blank=True), + required=False, + allow_null=True) + + class AffectedvmSerializer(serializers.Serializer): extention = serializers.CharField( help_text="extention", @@ -66,13 +88,13 @@ class HealReqSerializer(serializers.Serializer): affectedvm = AffectedvmSerializer(help_text='affectedvm', many=True) -class HealRespSerializer(serializers.Serializer): - jobid = serializers.CharField( +class InstScaleHealRespSerializer(serializers.Serializer): + jobId = serializers.CharField( help_text="jobid", max_length=255, required=True, allow_null=True) - nfInstanceId = serializers.CharField( + vnfInstanceId = serializers.CharField( help_text="nfInstanceId", max_length=255, required=True, diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py index 24c7fbdf..fb0f7679 100644 --- a/zte/vmanager/driver/interfaces/tests.py +++ b/zte/vmanager/driver/interfaces/tests.py @@ -351,7 +351,10 @@ class InterfacesTest(TestCase): @mock.patch.object(restcall, 'call_req') def test_scale(self, mock_call_req): - job_info = {"jobid": "801", "nfInstanceId": "101"} + job_info = { + "jobId": "801", + "vnfInstanceId": "101" + } vnfm_info = { "userName": "admin", "vendor": "ZTE", @@ -435,8 +438,8 @@ class InterfacesTest(TestCase): @mock.patch.object(restcall, 'call_req') def test_heal(self, mock_call_req): job_info = { - "jobid": "12234455", - "nfInstanceId": "10144445666" + "jobId": "12234455", + "vnfInstanceId": "10144445666" } vnfm_info = { "userName": "admin", diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index 485657e2..949949b4 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -15,8 +15,8 @@ import inspect import json import logging -import traceback import os +import traceback from drf_yasg.utils import swagger_auto_schema from rest_framework import status @@ -24,10 +24,10 @@ from rest_framework.decorators import api_view from rest_framework.response import Response from rest_framework.views import APIView -from driver.interfaces.serializers import HealReqSerializer, HealRespSerializer +from driver.interfaces.serializers import HealReqSerializer, InstScaleHealRespSerializer +from driver.pub.config.config import VNF_FTP from driver.pub.utils import restcall from driver.pub.utils.restcall import req_by_msb -from driver.pub.config.config import VNF_FTP logger = logging.getLogger(__name__) @@ -441,7 +441,7 @@ class Heal(APIView): @swagger_auto_schema( request_body=HealReqSerializer(), responses={ - status.HTTP_202_ACCEPTED: HealRespSerializer(), + status.HTTP_202_ACCEPTED: InstScaleHealRespSerializer(), status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" } ) @@ -483,7 +483,7 @@ class Heal(APIView): raise Exception('heal error') resp_data = json.JSONDecoder().decode(ret[1]) logger.info("resp_data=%s", resp_data) - healRespSerializer = HealRespSerializer(data=resp_data) + healRespSerializer = InstScaleHealRespSerializer(data=resp_data) if not healRespSerializer.is_valid(): raise Exception(healRespSerializer.errors) diff --git a/zte/vmanager/driver/swagger/swagger.json b/zte/vmanager/driver/swagger/swagger.json index 0378e6ec..dfe53df9 100644 --- a/zte/vmanager/driver/swagger/swagger.json +++ b/zte/vmanager/driver/swagger/swagger.json @@ -4,7 +4,7 @@ "version": "1.0.0", "title": "ZTE VNFM Driver Service rest API" }, - "basePath": "/api/{vnfmtype}/v1", + "basePath": "/api/ztevnfmdriver/v1", "tags": [ { "name": "ztevnfmdriver" @@ -395,7 +395,7 @@ "vnfInstanceId": { "type": "string" }, - "jobid": { + "jobId": { "type": "string" } } -- cgit 1.2.3-korg