diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-11-16 10:53:36 +0800 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-11-16 10:53:36 +0800 |
commit | 94e92a803c20a30582a2d42a99bae40a32352368 (patch) | |
tree | 2aab7e00bb290198a66603a7eb0c023ebf5eba2e | |
parent | 1910890afcb1bb63825fe505262839b061c75d19 (diff) |
Fix metadata format handling3.0.1-ONAP3.0.0-ONAP1.2.1
This patch fix metadata format handling in server create API.
Change-Id: I80da9b175f17bfca1465cc7c06e9d092dab0f459
Issue-ID: MULTICLOUD-405
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r-- | vio/vio/pub/vim/vimapi/nova/OperateServers.py | 7 | ||||
-rw-r--r-- | 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 |