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
|
# texte pour la machine
|
||||||
txt = u''
|
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'Machine : %s\n' % m['host'][0]
|
||||||
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in m['exempt']])
|
txt += u'destination : %s\n' % ', '.join([unicode(i) for i in m['exempt']])
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,31 @@
|
||||||
#! /usr/bin/env python
|
#!/bin/bash /usr/scripts/python.sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
from lc_ldap import shortcuts
|
||||||
sys.path.append('/usr/scripts/gestion')
|
|
||||||
|
|
||||||
from ldap_crans import crans_ldap, decode, AssociationCrans
|
ldap = shortcuts.lc_ldap_readonly()
|
||||||
|
|
||||||
db = crans_ldap()
|
machines = ldap.search(u"(|(portTCPin=*)(portTCPout=*)(portUDPin=*)(portUDPout=*))")
|
||||||
machines = db.search('portTCPin=*')['machine'] + db.search('portTCPout=*')['machine'] + db.search('portUDPin=*')['machine'] + db.search('portUDPout=*')['machine']
|
|
||||||
|
|
||||||
done = []
|
|
||||||
txts = []
|
txts = []
|
||||||
|
|
||||||
for m in machines :
|
for m in machines :
|
||||||
# on vérifie qu'on l'a pas encore traité
|
# On se fiche des machines crans
|
||||||
if m.ip() in done :
|
if m['objectClass'][0] not in ["machineFixe","machineWifi"]:
|
||||||
continue
|
continue
|
||||||
if m.proprietaire().__class__ == AssociationCrans :
|
|
||||||
continue
|
|
||||||
done.append(m.ip())
|
|
||||||
|
|
||||||
# texte pour la machine
|
# texte pour la machine
|
||||||
txt = u''
|
txt = u''
|
||||||
txt += u'Propriétaire : %s\n' % m.proprietaire().Nom()
|
txt += u'Propriétaire : %s\n' % str(m.proprio()).decode('utf8')
|
||||||
txt += u'Machine : %s\n' % m.nom()
|
txt += u'Machine : %s\n' % m['host'][0]
|
||||||
if m.portTCPin() :
|
if m['portTCPin']:
|
||||||
txt += u'ports TCP in : %s\n' % ' '.join(m.portTCPin())
|
txt += u'ports TCP in : %s\n' % ' '.join([unicode(port) for port in m['portTCPin']])
|
||||||
if m.portTCPout() :
|
if m['portTCPout']:
|
||||||
txt += u'ports TCP out : %s\n' % ' '.join(m.portTCPout())
|
txt += u'ports TCP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
||||||
if m.portUDPin() :
|
if m['portUDPin']:
|
||||||
txt += u'ports UDP in : %s\n' % ' '.join(m.portUDPin())
|
txt += u'ports UDP in : %s\n' % ' '.join([unicode(port) for port in m['portUDPin']])
|
||||||
if m.portUDPout() :
|
if m['portUDPout']:
|
||||||
txt += u'ports UDP out : %s\n' % ' '.join(m.portUDPout())
|
txt += u'ports UDP out : %s\n' % ' '.join([unicode(port) for port in m['portTCPout']])
|
||||||
|
|
||||||
txts.append(txt.strip())
|
txts.append(txt.strip())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue