Adapts new API response schema

This PR makes troveclient to handle API response in new data schema.
Trove API response data schema has changed by the commit[1].

Original problem is that python-troveclient can't parse a API response
data in new data schema, resulting in an error.

[1]: 429c39890e

Task: 44986
Story: 2009979
Change-Id: I2e446c68c3b82c11d13f6bace54273c109e02069
This commit is contained in:
Hirotaka Wakabayashi 2022-04-08 04:06:30 +09:00
parent ef88f4d6c0
commit 2dbbf5656e
1 changed files with 7 additions and 1 deletions

View File

@ -35,7 +35,13 @@ def set_attributes_for_print_detail(cluster):
info['task_name'] = cluster.task['name']
info.pop('task', None)
if hasattr(cluster, 'ip'):
info['ip'] = ', '.join(cluster.ip)
ip = []
for addr in cluster.ip:
if isinstance(addr, dict):
ip.append(addr['address'])
else:
ip.append(addr)
info['ip'] = ', '.join(ip)
instances = info.pop('instances', None)
if instances:
info['instance_count'] = len(instances)