mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #23955 from rallytime/bp-19305
Backport #19305 to 2015.5
This commit is contained in:
commit
da3f9197d3
1 changed files with 29 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue