Merge pull request #23955 from rallytime/bp-19305

Backport #19305 to 2015.5
This commit is contained in:
Justin Findlay 2015-05-19 21:03:55 -06:00
commit da3f9197d3

View file

@ -154,17 +154,22 @@ def list_nodes(call=None):
'The list_nodes function must be called with -f or --function.'
)
items = query(method='droplets')
fetch = True
page = 1
ret = {}
for node in items['droplets']:
ret[node['name']] = {
'id': node['id'],
'image': node['image']['name'],
'networks': str(node['networks']),
'size': node['size_slug'],
'state': str(node['status']),
}
while fetch:
items = query(method='droplets', command='?page=' + str(page))
for node in items['droplets']:
ret[node['name']] = {
'id': node['id'],
'image': node['image']['name'],
'networks': str(node['networks']),
'size': node['size_slug'],
'state': str(node['status']),
}
page += 1
fetch = 'next' in items['links']['pages']
return ret
@ -177,16 +182,21 @@ def list_nodes_full(call=None, forOutput=True):
'The list_nodes_full function must be called with -f or --function.'
)
items = query(method='droplets')
fetch = True
page = 1
ret = {}
for node in items['droplets']:
ret[node['name']] = {}
for item in node.keys():
value = node[item]
if value is not None and forOutput:
value = str(value)
ret[node['name']][item] = value
while fetch:
items = query(method='droplets', command='?page=' + str(page))
for node in items['droplets']:
ret[node['name']] = {}
for item in node.keys():
value = node[item]
if value is not None and forOutput:
value = str(value)
ret[node['name']][item] = value
page += 1
fetch = 'next' in items['links']['pages']
return ret