
Ignore-this: 1a03894b0e7eee239fe5a3b415594cc6 darcs-hash:20120807230017-108b1-719379098a34feeda0126b5b5317c56386077434.gz
56 lines
1.2 KiB
Python
56 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# slon-get-volume-mapping.py
|
|
# --------------------------
|
|
# Copyright : (c) 2012, Olivier Iffrig <iffrig@crans.org>
|
|
# Copyright : (c) 2008, Jeremie Dimino <dimino@crans.org>
|
|
# Licence : BSD3
|
|
|
|
u'''Outil pour récupérer le mapping lun/volume depuis la baie de
|
|
stockage'''
|
|
|
|
import slonlib, re, sys
|
|
|
|
sys.path.append("/usr/scripts/gestion")
|
|
from config import ISCSI_MAP_FILE_TEMPLATE
|
|
import affich_tools
|
|
|
|
map_file = ISCSI_MAP_FILE_TEMPLATE % "slon"
|
|
|
|
print u"Connection à la baie de stockage..."
|
|
|
|
slon = slonlib.Slon()
|
|
|
|
print u"Récupération des informations..."
|
|
|
|
map = slon.volume_map().items()
|
|
map.sort()
|
|
|
|
print u"Déconnection..."
|
|
|
|
slon.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"Terminé, mapping enregistré dans %s" % map_file
|
|
|
|
print u"Le mapping actuel est:"
|
|
print affich_tools.tableau(titre = ["lun", "nom"], data = map, alignement = ["g", "c"])
|