Commit 35e3ff03 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

wip slapgrid tests are passing with new API

parent cb36a56e
......@@ -574,7 +574,7 @@ stderr_logfile_backups=1
"portal_type": "Software Instance",
"compute_partition_id": partition.getId(),
"state": partition.getState(),
"software_type": self.getInstanceParameterDict().get(
"software_type": partition.getInstanceParameterDict().get(
'slap_software_type', None),
"parameters": partition.getInstanceParameterDict(),
"instance_processing_timestamp": partition.getInstanceParameterDict().get(
......
......@@ -82,9 +82,8 @@ class Manager(object):
# Get partitions IPv6 address
computer_partition = partition.computer_partition
parameter_dict = computer_partition.getInstanceParameterDict()
partition_ip_list = parameter_dict['ip_list'] + parameter_dict.get(
partition_ip_list = computer_partition['ip_list'] + computer_partition.get(
'full_ip_list', [])
partition_ip_list = [tup[1] for tup in partition_ip_list]
......
......@@ -719,6 +719,36 @@ class SlapConnectionHelper(ConnectionHelper):
return loads(xml)
# https://stackoverflow.com/a/33571117
def _byteify(data, ignore_dicts = False):
if isinstance(data, str):
return data
# if this is a list of values, return list of byteified values
if isinstance(data, list):
return [ _byteify(item, ignore_dicts=True) for item in data ]
# if this is a dictionary, return dictionary of byteified keys and values
# but only if we haven't already byteified it
if isinstance(data, dict) and not ignore_dicts:
return {
_byteify(key, ignore_dicts=True): _byteify(value, ignore_dicts=True)
for key, value in data.items() # changed to .items() for python 2.7/3
}
# python 3 compatible duck-typing
# if this is a unicode string, return its string representation
if str(type(data)) == "<type 'unicode'>":
return data.encode('utf-8')
# if it's anything else, return it in its original form
return data
def json_loads_byteified(json_text):
return _byteify(
json.loads(json_text, object_hook=_byteify),
ignore_dicts=True
)
class JioAPIConnectionHelper(ConnectionHelper):
def apiCall(self, path, data):
......@@ -727,7 +757,7 @@ class JioAPIConnectionHelper(ConnectionHelper):
data=json.dumps(data),
headers={'Content-type': 'application/json'},
expect_json_error=True)
return req.json()
return json_loads_byteified(req.text)
def get(self, data):
return self.apiCall(path="get/",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment