Fixes droplet listing past page 1

Affects creation and deletion (both failed if VM was outside page 1)
This commit is contained in:
TaiSHiNet 2014-12-30 19:37:00 -03:00 committed by rallytime
parent 02a78fce3d
commit bbf2429bce

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