[modules iscsi] On transforme udev-update-symlinks pour gérer "proprement" la redondance
This commit is contained in:
parent
a78a22eed5
commit
d834d23fa2
7 changed files with 140 additions and 100 deletions
56
gestion/iscsi/nols_get_volume_mapping.py
Normal file
56
gestion/iscsi/nols_get_volume_mapping.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
#!/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
|
||||
import affich_tools
|
||||
|
||||
map_file = ISCSI_MAP_FILE
|
||||
|
||||
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"])
|
Loading…
Add table
Add a link
Reference in a new issue