From 0f194550cc4a947e27ef70e48c636ed31d45e97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sun, 3 Mar 2013 04:17:12 +0100 Subject: [PATCH] =?UTF-8?q?[whos]=20Option=20-6=20ou=20--ipv6=20pour=20aff?= =?UTF-8?q?icher=20les=20ipv6=20en=20mode=20list=5Fmachines=20ou=20list=5F?= =?UTF-8?q?bornes,=20et=20on=20essaye=20plus=20d'avoir=20l'=C3=A9tat=20des?= =?UTF-8?q?=20bornes=20quand=20on=20les=20liste=20(trop=20long)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/whos.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/gestion/whos.py b/gestion/whos.py index 0ddb8a30..1bb2a9e3 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -38,6 +38,7 @@ d'historique affichées (défaut %(limit_aff_historique)i) -d ou --limit-blacklist= : limitation du nombre de lignes d'historique des déconnexions affichées (défaut %(limit_aff_blacklist)i) -s ou --ssh : affiche les fingerprint ssh des machines + -6 ou --ipv6 : affiche les ipv6 dans l'affichage synthétique """ try: @@ -66,6 +67,7 @@ limit_aff_historique = 4 limit_aff_blacklist = 4 aff_ipsec = 0 aff_ssh = 0 +aff_ipv6 = 0 ################################################################################ ### Fonctions utiles @@ -338,12 +340,17 @@ def list_machines(machines) : t, bl = __bases_machines(m) # Données - data.append([m.id(), m.rid(), t, m.nom().split('.')[0], m.ip(), m.ipv6(), m.mac(), bl]) + if not aff_ipv6: + data.append([m.id(), m.rid(), t, m.nom().split('.')[0], m.ip(), m.mac(), bl]) + larg = 15 + else: + larg = 22 + data.append([m.id(), m.rid(), t, m.nom().split('.')[0], m.ipv6(), m.mac(), bl]) return tableau(data, - titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse IPv6', u'Adresse MAC', u'Limitation'], - largeur = [5, 5, 4, '*', 15, 22, 17, 10], - alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c', 'c']) + titre = [u'mid', u'rid', u'Type', u'Nom de machine', u'Adresse IP', u'Adresse MAC', u'Limitation'], + largeur = [5, 5, 4, '*', larg, 17, 10], + alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c']) def list_bornes(bornes) : """ @@ -376,22 +383,20 @@ def list_bornes(bornes) : except : l = u'????' - if borne_etat(b.nom()): - etat = ok - else: - etat = nok - if '-' in b.puissance() : puiss = coul(b.puissance(),'rouge') else : puiss = b.puissance() - data.append([b.id(), b.rid(), b.nom().split('.')[0], b.ip(), b.mac(), etat, b.canal(), puiss, b.prise(), l]) + if aff_ipv6: + data.append([b.id(), b.rid(), b.nom().split('.')[0], b.ipv6(), b.mac(), b.canal(), puiss, b.prise(), l]) + else: + data.append([b.id(), b.rid(), b.nom().split('.')[0], b.ip(), b.mac(), b.canal(), puiss, b.prise(), l]) return u"Can=canaux, P=puissance, E=état\n" + \ tableau(data, - titre = [u'mid', u'rid', u'Nom', u'Adresse IP', u'Adresse MAC', u'E', u'Can', u'P', u'Pris', u'Lieu'], - largeur = [5, 5, 23, 15, 17, 1, 5, 3, 4, '*'], + titre = [u'mid', u'rid', u'Nom', u'Adresse IP', u'Adresse MAC', u'Can', u'P', u'Pris', u'Lieu'], + largeur = [5, 5, 16, 22, 17, 1, 5, 3, 4, '*'], alignement = ['d', 'd', 'c', 'c', 'c', 'c', 'c', 'c', 'g', 'c']) def adher_details(adher) : @@ -1112,7 +1117,7 @@ def __recherche() : """ Recherche et affichage des résultats à partir des options founies (sys.argv) """ - global aff_ipsec, aff_ssh, limit_aff_details, limit_aff_historique, limit_aff_blacklist, debug + global aff_ipsec, aff_ssh, limit_aff_details, limit_aff_historique, limit_aff_blacklist, debug, aff_ipv6 # Récupération des options if len(sys.argv) == 1 : @@ -1120,7 +1125,7 @@ def __recherche() : __usage_brief() try : - options, arg = getopt.getopt(sys.argv[1:], 'hamcstbil:L:d:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'limit-blacklist=', 'ipsec', 'crans', 'ssh' ]) + options, arg = getopt.getopt(sys.argv[1:], 'hamcs6tbil:L:d:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'limit-blacklist=', 'ipsec', 'crans', 'ssh', 'ipv6' ]) except getopt.error, msg : __usage_brief(unicode(msg)) @@ -1185,6 +1190,8 @@ def __recherche() : aff_ipsec = 1 elif opt in [ '-s', '--ssh' ]: aff_ssh = 1 + elif opt in [ '-6', '--ipv6' ]: + aff_ipv6 = 1 if only_adh + only_mac + only_club + only_bornes > 1 : __usage_brief(u'Options utilisées incompatibles')