summaryrefslogtreecommitdiffstats
path: root/share/newton_base/openoapi/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/newton_base/openoapi/server.py')
-rw-r--r--share/newton_base/openoapi/server.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py
index ba77dc55..cf2fffef 100644
--- a/share/newton_base/openoapi/server.py
+++ b/share/newton_base/openoapi/server.py
@@ -169,17 +169,17 @@ class Servers(APIView):
logger.info("request returns with status %s" % resp.status_code)
logger.debug("Servers--dettachVolume resp status::>%s" % resp.status_code)
- def _convert_metadata(self, metadata, metadata_output, reverse=True):
+ def _convert_metadata(self, metadata_vfc, metadata_openstack, reverse=True):
if not reverse:
- # from extraSpecs to extra_specs
- for spec in metadata:
- metadata_output[spec['keyName']] = spec['value']
+ # from vfc format to openstack format
+ for spec in metadata_vfc:
+ metadata_openstack[spec['keyName']] = spec['value']
else:
- for k, v in metadata_output.items():
+ for k, v in metadata_openstack.items():
spec = {}
spec['keyName'] = k
spec['value'] = v
- metadata.append(spec)
+ metadata_vfc.append(spec)
def _convert_resp(self, server):
#convert volumeArray
@@ -274,11 +274,11 @@ class Servers(APIView):
if not serverid:
# convert the key naming in servers
for server in content["servers"]:
- metadata = server.pop("metadata", None)
- if metadata:
- meta_data = []
- self._convert_metadata(metadata, meta_data, False)
- server["metadata"] = meta_data
+ metadata_openstack = server.pop("metadata", None)
+ if metadata_openstack:
+ metadata_vfc = []
+ self._convert_metadata(metadata_vfc, metadata_openstack, True)
+ server["metadata"] = metadata_vfc
VimDriverUtils.replace_key_by_mapping(server,
self.keys_mapping)
self._convert_resp(server)
@@ -287,11 +287,11 @@ class Servers(APIView):
else:
# convert the key naming in the server specified by id
server = content.pop("server", None)
- metadata = server.pop("metadata", None)
- if metadata:
- meta_data = []
- self._convert_metadata(metadata, meta_data)
- server["metadata"] = meta_data
+ metadata_openstack = server.pop("metadata", None)
+ if metadata_openstack:
+ metadata_vfc = []
+ self._convert_metadata(metadata_vfc, metadata_openstack, True)
+ server["metadata"] = metadata_vfc
VimDriverUtils.replace_key_by_mapping(server,
self.keys_mapping)
self._convert_resp(server)
@@ -353,11 +353,11 @@ class Servers(APIView):
if len(networks) > 0:
server["networks"] = networks
- meta_data = server.pop("metadata", None)
- if meta_data:
- metadata = {}
- self._convert_metadata(metadata, meta_data, False)
- server["metadata"] = metadata
+ metadata_vfc = server.pop("metadata", None)
+ if metadata_vfc:
+ metadata_openstack = {}
+ self._convert_metadata(metadata_vfc, metadata_openstack, False)
+ server["metadata"] = metadata_openstack
contextarray = server.pop("contextArray", None)
volumearray = server.pop("volumeArray", None)
@@ -404,11 +404,11 @@ class Servers(APIView):
volumeIds = [extraVolume["volumeId"] for extraVolume in volumearray]
self._attachVolume(vimid, tenantid, resp_body["id"], *volumeIds)
- metadata = resp_body.pop("metadata", None)
- if metadata:
- meta_data = []
- self._convert_metadata(metadata, meta_data)
- resp_body["metadata"] = meta_data
+ metadata_openstack = resp_body.pop("metadata", None)
+ if metadata_openstack:
+ metadata_vfc = []
+ self._convert_metadata(metadata_vfc, metadata_openstack, True)
+ resp_body["metadata"] = metadata_vfc
VimDriverUtils.replace_key_by_mapping(resp_body, self.keys_mapping)
vim_dict = {