scripts/gestion/tools/locate-mac.py
salles 380bddb8f5 Plus de dtails comme a
C'est toujours porki mais bon, une apprenti-nounou passera derrire pour
mettre en application le cours de fred.

darcs-hash:20051020105121-72cb0-2b4f87e7fcc3d945ecfd96006e48a29e04d25af4.gz
2005-10-20 12:51:21 +02:00

38 lines
1.1 KiB
Python
Executable file

#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
import sys
sys.path.append('/usr/scripts/gestion')
from annuaires import reverse, all_switchs
from hptools import hpswitch
from time import sleep
from os import system
import threading
mac = ":".join([i.zfill(2) for i in sys.argv[1].split(":")]).lower()
# on interroge les switchs
# classe d'interrogation des switchs
class interroge_switch (threading.Thread) :
def __init__ (self, switch, mac = None) :
threading.Thread.__init__(self)
self.switch = switch
self.mac = mac
self.start()
def run (self) :
sw = hpswitch(self.switch)
prise = sw.where_is_mac(mac)
if prise != None :
print "%-10s => prise %-2s : %s" % (self.switch.encode('iso-8859-15').replace('.adm.crans.org',''), str(prise), sw.nom(None, prise))
# on onterroge trois fois car il donne pas toujours les clients
for switch in ['backbone'] + all_switchs():
interroge_switch(switch, mac)
while len(threading.enumerate()) > 1 :
sleep(1)
print
system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)