scripts/utils/list_exempt.py
Pierre-Elliott Bécue 94ee83b86a Nettoie list_firewall.py, plus un oublie dans list_exempt
* output est une liste d'unicodes, mieux vaut .join() sur un unicode
2015-08-18 04:15:43 +02:00

29 lines
988 B
Python
Executable file

#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
#
# list_exempt.py --- Fournit la liste des machines avec une exemption.
"""Fournit une liste des machines d'adhérents disposant d'une exemption"""
from lc_ldap import shortcuts
from config.encoding import out_encoding
def make_output(ldap):
"""Génère le texte à afficher"""
machines_avec_exemption = ldap.search(u"exempt=*")
output = []
for machine in machines_avec_exemption:
# texte pour la machine
txt = u''
txt += u'Propriétaire : %s\n' % machine.proprio()
txt += u'Machine : %s\n' % machine['host'][0]
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in machine['exempt']])
output.append(txt.strip())
return output
if __name__ == '__main__':
LDAP = shortcuts.lc_ldap_readonly()
OUTPUT = make_output(LDAP)
print u'\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(OUTPUT).encode(out_encoding)