From 312eaa87aad223fb92849c0062fb6b123c4e984c Mon Sep 17 00:00:00 2001 From: xinhuili Date: Wed, 15 Mar 2017 03:38:46 -0700 Subject: Add fix to status and volume This patch is to fix several points. Change-Id: I75225bb58fd488ebaaee56234c692a76be0295c7 Issue-ids: MULTIVIM-36 Signed-off-by: xinhuili --- vio/vio/swagger/nova_utils.py | 1 + vio/vio/swagger/views/volume/views.py | 6 ++++++ vio/vio/swagger/volume_utils.py | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vio/vio/swagger/nova_utils.py b/vio/vio/swagger/nova_utils.py index ac48ac9..97dc5be 100644 --- a/vio/vio/swagger/nova_utils.py +++ b/vio/vio/swagger/nova_utils.py @@ -28,6 +28,7 @@ def server_formatter(server, interfaces=[]): "contextArray": [], "userdata": server.user_data, "nicArray": [], + "status": server.status } if interfaces: r['nicArray'] = [{'portId': i.port_id} for i in interfaces] diff --git a/vio/vio/swagger/views/volume/views.py b/vio/vio/swagger/views/volume/views.py index 47c6903..73a20e6 100644 --- a/vio/vio/swagger/views/volume/views.py +++ b/vio/vio/swagger/views/volume/views.py @@ -114,6 +114,12 @@ class CreateListVolumeView(APIView): rsp.update(vim_rsp) return Response(data=rsp, status=status.HTTP_200_OK) + if body.get('imageName'): + image_op = OperateImage.OperateImage(vim_info) + imageName = body.get('imageName') + image = image_op.find_vim_image(imageName) + body['imageId'] = image.id + param = volume_utils.req_body_formatter(body) volume_info = volume_op.create_vim_volume(**param) diff --git a/vio/vio/swagger/volume_utils.py b/vio/vio/swagger/volume_utils.py index 21c2732..44fcbd7 100644 --- a/vio/vio/swagger/volume_utils.py +++ b/vio/vio/swagger/volume_utils.py @@ -60,11 +60,13 @@ def sdk_param_formatter(data): def req_body_formatter(body): param = {} + param['name'] = body.get('name') param['size'] = body.get('volumeSize') + if body.get('volumeType'): param['volume_type'] = body.get('volumeType') - param['name'] = body.get('name') if body.get('availabilityZone'): param['availability_zone'] = body.get('availabilityZone') - param['image_id'] = body.get('imageId') + if body.get('imageId'): + param['image_id'] = body.get('imageId') return param -- cgit 1.2.3-korg