recuperation des infos sous la forme d'une string
darcs-hash:20061004225743-f6463-04f78a52b1cdda09426ab1bc437a15020e6bedb8.gz
This commit is contained in:
parent
245a057bca
commit
9bf29bf91a
1 changed files with 10 additions and 5 deletions
|
@ -16,8 +16,9 @@ def format_mac(unformated_mac):
|
|||
|
||||
# classe d'interrogation des switchs
|
||||
class interroge_switch (threading.Thread) :
|
||||
def __init__ (self, switch, mac = None) :
|
||||
def __init__ (self, tableau, switch, mac = None) :
|
||||
threading.Thread.__init__(self)
|
||||
self.tableau=tableau
|
||||
self.switch = switch
|
||||
self.mac = mac
|
||||
self.start()
|
||||
|
@ -26,19 +27,23 @@ class interroge_switch (threading.Thread) :
|
|||
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))
|
||||
self.tableau.append("%-10s => prise %-2s : %s" % (self.switch.encode('iso-8859-15').replace('.adm.crans.org',''), str(prise), sw.nom(None, prise)))
|
||||
|
||||
# interrogation des switchs en parallele
|
||||
def print_trace(mac):
|
||||
def get_trace(mac):
|
||||
|
||||
tableau=[]
|
||||
|
||||
for switch in ['backbone'] + all_switchs():
|
||||
interroge_switch(switch, mac)
|
||||
interroge_switch(tableau,switch, mac)
|
||||
|
||||
while len(threading.enumerate()) > 1 :
|
||||
sleep(1)
|
||||
|
||||
return '\n'.join(tableau)
|
||||
|
||||
# on interroge les switchs et on fait un whos sur la mac
|
||||
if __name__ == '__main__':
|
||||
mac = format_mac(sys.argv[1])
|
||||
print_trace(mac)
|
||||
print get_trace(mac)
|
||||
print system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue