summaryrefslogtreecommitdiffstats
path: root/zte
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2018-02-07 10:10:13 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2018-02-07 10:10:13 +0800
commitac847137bc2a6ff4291378e93e70f80d1ef530a5 (patch)
tree10939d74819bd86e31a401d34beadae50c22d1bf /zte
parentbbda034c33755886b4e2e266fd7863a1038b5931 (diff)
Add vfc-ztevnfmdriver scale auto-swagger
Change-Id: Ia0c5101f10f809d37bbbc3cc8af40f0992f54d4e Issue-ID: VFC-736 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'zte')
-rw-r--r--zte/vmanager/driver/interfaces/serializers.py2
-rw-r--r--zte/vmanager/driver/interfaces/views.py25
2 files changed, 19 insertions, 8 deletions
diff --git a/zte/vmanager/driver/interfaces/serializers.py b/zte/vmanager/driver/interfaces/serializers.py
index fbe7660d..1792c2cd 100644
--- a/zte/vmanager/driver/interfaces/serializers.py
+++ b/zte/vmanager/driver/interfaces/serializers.py
@@ -32,7 +32,7 @@ class ScaleReqSerializer(serializers.Serializer):
allow_null=True)
additionalParam = serializers.DictField(
help_text="additionalParam",
- child=serializers.CharField(allow_blank=True),
+ child=serializers.DictField(allow_null=True),
required=False,
allow_null=True)
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py
index 820cd823..5b13487c 100644
--- a/zte/vmanager/driver/interfaces/views.py
+++ b/zte/vmanager/driver/interfaces/views.py
@@ -406,13 +406,18 @@ class Scale(APIView):
try:
logger.info("request.data = %s", request.data)
logger.info("requested_url = %s", request.get_full_path())
+ scaleReqSerializer = ScaleReqSerializer(data=request.data)
+ if not scaleReqSerializer.is_valid():
+ raise Exception(scaleReqSerializer.errors)
+
ret = get_vnfminfo_from_nslcm(vnfmid)
if ret[0] != 0:
- return Response(data={'error': ret[1]}, status=ret[2])
+ raise Exception(ret[1])
+
vnfm_info = json.JSONDecoder().decode(ret[1])
- scale_type = ignorcase_get(request.data, "type")
- aspect_id = ignorcase_get(request.data, "aspectId")
- number_of_steps = ignorcase_get(request.data, "numberOfSteps")
+ scale_type = ignorcase_get(scaleReqSerializer.data, "type")
+ aspect_id = ignorcase_get(scaleReqSerializer.data, "aspectId")
+ number_of_steps = ignorcase_get(scaleReqSerializer.data, "numberOfSteps")
data = {
'vnfmid': vnfmid,
'nfvoid': 1,
@@ -432,10 +437,15 @@ class Scale(APIView):
content=json.JSONEncoder().encode(data))
logger.info("ret=%s", ret)
if ret[0] != 0:
- return Response(data={'error': 'scale error'}, status=ret[2])
+ raise Exception('scale error')
+
resp_data = json.JSONDecoder().decode(ret[1])
logger.info("resp_data=%s", resp_data)
- return Response(data=resp_data, status=status.HTTP_202_ACCEPTED)
+ scaleRespSerializer = InstScaleHealRespSerializer(data=resp_data)
+ if not scaleRespSerializer.is_valid():
+ raise Exception(scaleRespSerializer.errors)
+
+ return Response(data=scaleRespSerializer.data, status=status.HTTP_202_ACCEPTED)
except Exception as e:
logger.error("Error occurred when scaling VNF,error:%s", e.message)
logger.error(traceback.format_exc())
@@ -461,7 +471,8 @@ class Heal(APIView):
ret = get_vnfminfo_from_nslcm(vnfmid)
if ret[0] != 0:
- return Response(data={'error': ret[1]}, status=ret[2])
+ raise Exception(ret[1])
+
vnfm_info = json.JSONDecoder().decode(ret[1])
data = {}
data['action'] = ignorcase_get(healReqSerializer.data, 'action')