From 94e92a803c20a30582a2d42a99bae40a32352368 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Fri, 16 Nov 2018 10:53:36 +0800 Subject: Fix metadata format handling This patch fix metadata format handling in server create API. Change-Id: I80da9b175f17bfca1465cc7c06e9d092dab0f459 Issue-ID: MULTICLOUD-405 Signed-off-by: Ethan Lynn --- vio/vio/pub/vim/vimapi/nova/OperateServers.py | 7 +++++-- vio/vio/swagger/nova_utils.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vio/vio/pub/vim/vimapi/nova/OperateServers.py b/vio/vio/pub/vim/vimapi/nova/OperateServers.py index b14c7f4..289fbc9 100644 --- a/vio/vio/pub/vim/vimapi/nova/OperateServers.py +++ b/vio/vio/pub/vim/vimapi/nova/OperateServers.py @@ -59,9 +59,12 @@ class OperateServers(OperateNova): az = create_req.get('availabilityZone', None) if az: req['availability_zone'] = az - md = create_req.get('metadata', []) + # md = create_req.get('metadata', []) + # if md: + # req['metadata'] = {n['keyName']: n['value'] for n in md} + md = create_req.get('metadata', {}) if md: - req['metadata'] = {n['keyName']: n['value'] for n in md} + req['metadata'] = md userdata = create_req.get('userdata', None) if userdata: req['user_data'] = base64.encodestring(userdata) diff --git a/vio/vio/swagger/nova_utils.py b/vio/vio/swagger/nova_utils.py index cf9c970..ebed57d 100644 --- a/vio/vio/swagger/nova_utils.py +++ b/vio/vio/swagger/nova_utils.py @@ -21,7 +21,7 @@ def server_formatter(server, interfaces=[]): "availabilityZone": server.availability_zone, "flavorId": server.flavor_id or server.flavor['id'], "volumeArray": [], - "metadata": [], + "metadata": {}, "securityGroups": [], # TODO finish following attributes "serverGroup": "", @@ -55,8 +55,9 @@ def server_formatter(server, interfaces=[]): 'volumeId': r['volumeArray'][0]['volumeId'] } if server.metadata: - r["metadata"] = [{'keyName': k, 'value': v} - for k, v in six.iteritems(server.metadata)] + # r["metadata"] = [{'keyName': k, 'value': v} + # for k, v in six.iteritems(server.metadata)] + r["metadata"] = server.metadata if server.security_groups: r["securityGroups"] = [i['name'] for i in server.security_groups] return r -- cgit 1.2.3-korg