[gestion/iscsi/slon-get-volume-mapping] produit un fichier human-readable
darcs-hash:20081216221512-c41ad-d7d7ffd4f12f08722d1a82b35f3cb3780403ce25.gz
This commit is contained in:
parent
5ab4a87493
commit
80fd857b14
1 changed files with 23 additions and 7 deletions
|
@ -9,7 +9,9 @@
|
||||||
u'''Outil pour récupérer le mapping lun/volume depuis la baie de
|
u'''Outil pour récupérer le mapping lun/volume depuis la baie de
|
||||||
stockage'''
|
stockage'''
|
||||||
|
|
||||||
import telnetlib, re
|
import telnetlib, re, sys
|
||||||
|
|
||||||
|
sys.path.append("/usr/scripts/gestion")
|
||||||
from config import ISCSI_MAP_FILE
|
from config import ISCSI_MAP_FILE
|
||||||
import affich_tools
|
import affich_tools
|
||||||
|
|
||||||
|
@ -77,17 +79,31 @@ junk = re.compile("Press any key to continue \(Q to quit\)\x0d *\x0d")
|
||||||
resp = junk.sub("", resp)
|
resp = junk.sub("", resp)
|
||||||
|
|
||||||
# Parsing de la réponse
|
# Parsing de la réponse
|
||||||
map={}
|
map = []
|
||||||
for m in volume_regexp.finditer(resp):
|
for m in volume_regexp.finditer(resp):
|
||||||
map[int(m.group(2))] = m.group(1)
|
map.append((int(m.group(2)), m.group(1)))
|
||||||
|
map.sort()
|
||||||
|
|
||||||
print u"Enregistrement des informations..."
|
print u"Enregistrement des informations..."
|
||||||
|
|
||||||
file(ISCSI_MAP_FILE, "w").write("map = %s\n" % str(map))
|
f = open(ISCSI_MAP_FILE, "w")
|
||||||
|
f.write((u"""\
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Fichier de mapping lun -> nom de volume
|
||||||
|
#
|
||||||
|
# Ce fichier est généré par %s
|
||||||
|
|
||||||
|
map = {
|
||||||
|
""" % sys.argv[0]).encode("UTF-8"))
|
||||||
|
|
||||||
|
for lun, name in map:
|
||||||
|
f.write(' %d : "%s",\n' % (lun, name))
|
||||||
|
|
||||||
|
f.write("}\n")
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
print u"Terminé, mapping enregistré dans %s" % ISCSI_MAP_FILE
|
print u"Terminé, mapping enregistré dans %s" % ISCSI_MAP_FILE
|
||||||
|
|
||||||
print u"Le mapping actuel est:"
|
print u"Le mapping actuel est:"
|
||||||
l = [[lun, name] for lun, name in map.iteritems()]
|
print affich_tools.tableau(titre = ["lun", "nom"], data = map, alignement = ["g", "c"])
|
||||||
l.sort()
|
|
||||||
print affich_tools.tableau(titre = ["lun", "nom"], data = l, alignement = ["g", "c"])
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue