Support des fonctions de whokfet (--all notamment pour les nounous)
This commit is contained in:
parent
9cb259ea71
commit
c0a2697aea
1 changed files with 23 additions and 8 deletions
|
@ -37,6 +37,11 @@ DN_CRANS = 'ou=data,dc=crans,dc=org'
|
|||
|
||||
WIFIMAP_DIR = os.getenv('DBG_WIFIMAP_DB', '/usr/scripts/var/wifi_xml')
|
||||
|
||||
# Par défaut, l'affichage est limité et on ne prévient pas des machines manquantes
|
||||
privacy = True
|
||||
warn = False
|
||||
|
||||
|
||||
def missing_tpe():
|
||||
"""Envoie un mail si le tpe n'est pas présent avec l'arg --warn-tpe"""
|
||||
dst = 'respbats@crans.org'
|
||||
|
@ -127,7 +132,7 @@ class WhosThere(object):
|
|||
if self._ignore_inactive:
|
||||
if unicode(m['objectClass'][0]) == u'machineWifi' or self._ignore_wifi_only:
|
||||
return
|
||||
key = 'adh'
|
||||
key = 'adh'
|
||||
res[key].append(m)
|
||||
else:
|
||||
res['unknown_macs'].append(mac)
|
||||
|
@ -265,7 +270,7 @@ class WhoKfet(WhosThere):
|
|||
]
|
||||
|
||||
def do_scan(self):
|
||||
self.set_ignore_inactive(False, wifi_only=False)
|
||||
self.set_ignore_inactive(privacy, wifi_only=privacy)
|
||||
self.populate_from_switch('backbone.adm.crans.org', 21)
|
||||
|
||||
class Who2B(WhosThere):
|
||||
|
@ -283,7 +288,7 @@ class Who2B(WhosThere):
|
|||
def do_scan(self):
|
||||
# Tous les gens au 2B sont supposés actifs (local technique quoi)
|
||||
# mais on cache quand-même les personnes connectées en WiFi
|
||||
self.set_ignore_inactive(True, wifi_only=True)
|
||||
self.set_ignore_inactive(privacy, wifi_only=privacy)
|
||||
self.populate_from_switch('backbone.adm.crans.org', 33)
|
||||
self.tty_server=u"vo"
|
||||
self.populate_from_tty()
|
||||
|
@ -299,7 +304,7 @@ class WhoDAlembert(WhosThere):
|
|||
class Who4J(WhosThere):
|
||||
name = u"4J"
|
||||
def do_scan(self):
|
||||
self.set_ignore_inactive(True, wifi_only=True)
|
||||
self.set_ignore_inactive(privacy, wifi_only=privacy)
|
||||
self.populate_from_switch('batj-3.adm.crans.org', 7)
|
||||
self.tty_server=u"cochon"
|
||||
self.populate_from_tty()
|
||||
|
@ -313,12 +318,22 @@ if __name__ == '__main__':
|
|||
}
|
||||
if '--warn-tpe' in sys.argv:
|
||||
warn=['tpe']
|
||||
else:
|
||||
warn=False
|
||||
if '--all' in sys.argv:
|
||||
cur_user = os.getenv("SUDO_USER") or os.getenv("USER")
|
||||
if cur_user:
|
||||
ldap = shortcuts.lc_ldap_readonly()
|
||||
user = ldap.search(u'uid=%s' % cur_user)
|
||||
if u'Nounou' in user[0]['droits']:
|
||||
privacy = False
|
||||
else:
|
||||
cprint("Vous n'avez pas les droits requis, --all ignoré.", 'jaune')
|
||||
for what in sys.argv[1:]:
|
||||
try:
|
||||
name = where[what.lower()]
|
||||
except KeyError:
|
||||
print "Usage: whosthere.py <local>\n Locaux : %s" % (", ".join(where.keys()))
|
||||
sys.exit(1)
|
||||
if what!='--all' and what!='--warn-tpe':
|
||||
print "Usage: whosthere.py <local>\n Locaux : %s" % (", ".join(where.keys()))
|
||||
sys.exit(1)
|
||||
else:
|
||||
continue
|
||||
name().summary()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue