
Ignore-this: cede81deef3853019d111b256ea6c957 darcs-hash:20130108192725-b6762-005f3e83427c245a66fd685ca871b1b6db954d3f.gz
56 lines
1.2 KiB
Python
Executable file
56 lines
1.2 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# nols-get-volume-mapping.py
|
|
# --------------------------
|
|
# Qui taper si ça marche pas : Pierre-Elliott Bécue <peb@crans.org>
|
|
# Merci à : Jérémie Dimino <jeremie@dimino.org>, je n'ai fait que s/slon/nols/ sur ce script.
|
|
# Licence : BSD3
|
|
|
|
u'''Outil pour récupérer le mapping lun/volume depuis la baie de
|
|
stockage'''
|
|
|
|
import nolslib, re, sys
|
|
|
|
sys.path.append("/usr/scripts/gestion")
|
|
from config import ISCSI_MAP_FILE_TEMPLATE
|
|
import affich_tools
|
|
|
|
map_file = ISCSI_MAP_FILE_TEMPLATE % "nols"
|
|
|
|
print u"Connexion a la baie de stockage..."
|
|
|
|
nols = nolslib.Nols()
|
|
|
|
print u"Recuperation des informations..."
|
|
|
|
map = nols.volume_map().items()
|
|
map.sort()
|
|
|
|
print u"Deconnexion..."
|
|
|
|
nols.logout()
|
|
|
|
print u"Enregistrement des informations..."
|
|
|
|
f = open(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"Termine, mapping enregistre dans %s" % map_file
|
|
|
|
print u"Le mapping actuel est:"
|
|
print affich_tools.tableau(titre = ["lun", "nom"], data = map, alignement = ["g", "c"])
|