From bfd4e48d99f804a7ccc50d263cbb118e51c325af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sat, 26 Jan 2013 11:21:58 +0100 Subject: [PATCH] [ldap_crans/rid] On vire le patch sale, le rid est en place. Patch de whos pour afficher chaque machine suivant sa plage d'ip Ignore-this: b93e7269facc6b9bbe0f294a8a03b6ca darcs-hash:20130126102158-afe24-b175fb636cd40276baa02542a5b075e0e54065e1.gz --- gestion/ldap_crans.py | 10 ---------- gestion/whos.py | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 15516ac4..7bbd2775 100644 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -1322,16 +1322,6 @@ class BaseClasseCrans(CransLdap): champ = c.args[0]['info'].split(':')[0] raise RuntimeError(u'Entrée en double dans le champ %s' % champ) - # l'ip change, le rid aussi... - if 'ipHostNumber' in self.modifs: - try: - rid = ridtools.Rid(ipv4 = self._data["ipHostNumber"][0]) - except ValueError: - pass - else: - self.rid('%d' % rid) - - ### Génération de la liste de services à redémarrer # Quasiement tout est traité dans les classes filles. if hasattr(self, "_blacklist_restart"): diff --git a/gestion/whos.py b/gestion/whos.py index 206d4284..6a7f0843 100644 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -56,6 +56,7 @@ from ldap_crans import is_actif, crans_ldap, ann_scol, AssociationCrans, hostnam from ldap_crans import MachineCrans, MachineWifi, BorneWifi from ldap_crans import Adherent from affich_tools import * +from config import rid import user_tests import subprocess, commands @@ -227,7 +228,8 @@ def machines_brief(machines) : """ Formatage sous forme d'un tableau des propriétés de la liste de machine : * mid - * type (fixe ou wifi, born) + * rid + * type (serveur, adm, fil, wifi, adm, borne) * nom * adresse IP * adresse MAC @@ -254,13 +256,13 @@ def machines_brief(machines) : p = coul(p,'rouge') # Données - data.append([m.id() , t, m.nom().split('.')[0], p, a.chbre(), bl]) + data.append([m.id(), m.rid() , t, m.nom().split('.')[0], p, a.chbre(), bl]) return u"Le propriétaire en rouge signale un problème administratif, en bleu une inscription gratuite\n" + \ tableau(data, - titre = [u'mid', u'Type', u'Nom de machine', u'Propriétaire', u'Chbre', u'Limitation'], - largeur = [5, 4, 18, '*', 5, 10], - alignement = ['d', 'c', 'c', 'c', 'g', 'c']) + titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Propriétaire', u'Chbre', u'Limitation'], + largeur = [5, 5, 13, 18, '*', 5, 10], + alignement = ['d', 'd', 'c', 'c', 'c', 'g', 'c']) def clubs_brief(clubs) : """ @@ -899,9 +901,14 @@ def _hist(clas) : def __bases_machines(m) : """ Retourne [ type de la machines, blacklist ] """ #Type - if isinstance(m, MachineWifi): t = 'wifi' - elif isinstance(m, BorneWifi): t = 'born' - else : t='fixe' + t = 'inconnu' + for tp, (start, end) in rid.iteritems(): + if start <= int(m.rid()) <= end: + t = tp + break + + if isinstance(m, BorneWifi): + t = "borne" # Déconnectée ? b = m.blacklist_actif()