1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix error with servers without group metadata. Add this servers to undefined group.

This commit is contained in:
Marco Vito Moscaritolo 2012-09-05 16:26:01 +02:00
parent d9e8a6c2e1
commit a2307aa7a0

View file

@ -94,14 +94,14 @@ if len(sys.argv) == 2 and (sys.argv[1] == '--list'):
# Cycle on servers
for f in client.servers.list():
# Define group (or set to empty string)
group = f.metadata['group'] if f.metadata['group'] else ''
group = f.metadata['group'] if f.metadata.has_key('group') else 'undefined'
# Create group if not exist
if group not in groups:
groups[f.metadata['group']] = []
groups[group] = []
# Append group to list
groups[f.metadata['group']].append(f.accessIPv4)
groups[group].append(f.accessIPv4)
# Return server list
print json.dumps(groups)