Version moins gourmande pour générer services.py
This commit is contained in:
parent
3fdbd50140
commit
a26eb6ed05
1 changed files with 9 additions and 7 deletions
|
@ -8,13 +8,15 @@ comment_start = "#"
|
|||
|
||||
header("Services configuré sur la machine")
|
||||
|
||||
#print metadata.query.names_by_groups(['firewall'])
|
||||
clients = metadata.query.all()
|
||||
groups_dict = {}
|
||||
|
||||
for client in clients:
|
||||
for group in client.groups:
|
||||
groups_dict.setdefault(group, []).append(client.hostname.split('.', 1)[0])
|
||||
|
||||
print "services = {"
|
||||
groups = list(metadata.groups)
|
||||
groups.sort()
|
||||
for group in groups:
|
||||
names = [ name.split('.', 1)[0] for name in metadata.query.names_by_groups([group])]
|
||||
names.sort()
|
||||
print " '%s':%s," % (group, names)
|
||||
for (group_name, clients) in groups_dict.iteritems():
|
||||
clients.sort()
|
||||
print " %s: %s" % (group_name, clients)
|
||||
print "}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue