list_firewall passe à lc_ldap
This commit is contained in:
parent
5f0247ffb3
commit
09a720b827
2 changed files with 20 additions and 26 deletions
|
@ -13,7 +13,7 @@ for m in machines :
|
|||
|
||||
# texte pour la machine
|
||||
txt = u''
|
||||
txt += u'Propriétaire : %s\n' % m.proprio()
|
||||
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
|
||||
txt += u'Machine : %s\n' % m['host'][0]
|
||||
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in m['exempt']])
|
||||
|
||||
|
|
|
@ -1,38 +1,32 @@
|
|||
#! /usr/bin/env python
|
||||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
from lc_ldap import shortcuts
|
||||
|
||||
from ldap_crans import crans_ldap, decode, AssociationCrans
|
||||
ldap = shortcuts.lc_ldap_readonly()
|
||||
|
||||
db = crans_ldap()
|
||||
machines = db.search('portTCPin=*')['machine'] + db.search('portTCPout=*')['machine'] + db.search('portUDPin=*')['machine'] + db.search('portUDPout=*')['machine']
|
||||
machines = ldap.search(u"(|(portTCPin=*)(portTCPout=*)(portUDPin=*)(portUDPout=*))")
|
||||
|
||||
done = []
|
||||
txts = []
|
||||
|
||||
for m in machines :
|
||||
# on vérifie qu'on l'a pas encore traité
|
||||
if m.ip() in done :
|
||||
# On se fiche des machines crans
|
||||
if m['objectClass'][0] not in ["machineFixe","machineWifi"]:
|
||||
continue
|
||||
if m.proprietaire().__class__ == AssociationCrans :
|
||||
continue
|
||||
done.append(m.ip())
|
||||
|
||||
|
||||
# texte pour la machine
|
||||
txt = u''
|
||||
txt += u'Propriétaire : %s\n' % m.proprietaire().Nom()
|
||||
txt += u'Machine : %s\n' % m.nom()
|
||||
if m.portTCPin() :
|
||||
txt += u'ports TCP in : %s\n' % ' '.join(m.portTCPin())
|
||||
if m.portTCPout() :
|
||||
txt += u'ports TCP out : %s\n' % ' '.join(m.portTCPout())
|
||||
if m.portUDPin() :
|
||||
txt += u'ports UDP in : %s\n' % ' '.join(m.portUDPin())
|
||||
if m.portUDPout() :
|
||||
txt += u'ports UDP out : %s\n' % ' '.join(m.portUDPout())
|
||||
|
||||
txt = u''
|
||||
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
|
||||
txt += u'Machine : %s\n' % m['host'][0]
|
||||
if m['portTCPin']:
|
||||
txt += u'ports TCP in : %s\n' % ' '.join([unicode(port) for port in m['portTCPin']])
|
||||
if m['portTCPout']:
|
||||
txt += u'ports TCP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
||||
if m['portUDPin']:
|
||||
txt += u'ports UDP in : %s\n' % ' '.join([unicode(port) for port in m['portUDPin']])
|
||||
if m['portUDPout']:
|
||||
txt += u'ports UDP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
||||
|
||||
txts.append(txt.strip())
|
||||
|
||||
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue