From 3b643b222bd3299ed0e8e525305f8c36dbc581ff Mon Sep 17 00:00:00 2001 From: pauget Date: Sun, 19 Sep 2004 22:40:56 +0200 Subject: [PATCH] Gestion switchs par snmp (momo, tu peux rcuprer ta multiprise, c'est trop chiant d'avoir un interrupteur dessus) darcs-hash:20040919204056-41617-272808c5ebb1c835d15af323318fce5dbb7fdca4.gz --- gestion/ldap_crans.py | 4 ++-- gestion/whos.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 118a89e4..f08ee420 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -30,7 +30,7 @@ from chgpass import chgpass from affich_tools import coul, prompt from time import sleep,localtime -import ldap_secret +from secrets import ldap_password, ldap_auth_dn random.seed() # On initialise le générateur aléatoire @@ -200,7 +200,7 @@ class crans_ldap : while not ok: try: self.conn = ldap.initialize(uri) - self.conn.bind_s(ldap_secret.auth_dn,ldap_secret.password,ldap.AUTH_SIMPLE) + self.conn.bind_s(ldap_auth_dn,ldap_password,ldap.AUTH_SIMPLE) ok = True except ldap.SERVER_DOWN : nbessais += 1 diff --git a/gestion/whos.py b/gestion/whos.py index 46665aa7..fc45da89 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -47,6 +47,7 @@ except: from ldap_crans import is_actif , crans_ldap, ann_scol, crans from affich_tools import * +from hptools import sw_chbre limit_aff_details = 1 limit_aff_historique = 4 @@ -308,7 +309,10 @@ def adher_details(adher) : f += coul(u'Chambre : ','gras') + u"%s " % chbre prise = adher.prise() if prise : - f += u'(prise %s)' % prise + f += u'(prise %s' % prise + f += prise_etat(chbre) + f += ')' + f += '\n' # Etudes @@ -458,7 +462,9 @@ def club_details(club) : f += coul(u'Local : ','gras') + "%s " % club.local() prise = club.prise() if prise : - f += '(prise %s)' % prise + f += '(prise %s' % prise + f += prise_etat(club.chbre()) + f += ')' f += '\n' # Paiement @@ -555,6 +561,26 @@ def __bases_machines(m) : return t , bl +def prise_etat(chbre) : + f = '' + try : + # On met aussi l'état + conn = sw_chbre(chbre) + result = conn.status() + if result['etat']=='up' : + f += ', ' + coul('machine branchée','vert') + if result['vitesse_max'] == '10Mbps' : + f+= ', ' + coul('prise en 10Mbps','jaune') + elif result['activée'] == 'down' : + f+= ', ' + coul('prise désactivée','rouge') + else : + f+= ', activée, lien non détecté' + except : + # Switch non manageable + pass + + return f + ############################################################################## ## Partie dévolue au système de recherche