[iscsi] Deux baies pour le prix d'une
This commit is contained in:
parent
d0d7f71576
commit
01eec6b164
7 changed files with 91 additions and 148 deletions
75
gestion/iscsi/get_volume_mapping.py
Normal file
75
gestion/iscsi/get_volume_mapping.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
#!/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
|
||||
import nolslib
|
||||
import re
|
||||
import sys
|
||||
|
||||
coding = "utf-8"
|
||||
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
from config import ISCSI_MAP_FILE
|
||||
import affich_tools
|
||||
|
||||
def get_mapping(baie_name):
|
||||
map_file = ISCSI_MAP_FILE % (baie_name,)
|
||||
print u"Connexion à la baie de stockage…".encode(coding)
|
||||
|
||||
if baie_name == "slon":
|
||||
baie = slonlib.Slon()
|
||||
else:
|
||||
baie = nolslib.Nols()
|
||||
|
||||
print u"Récupération des informations…".encode(coding)
|
||||
|
||||
map = baie.volume_map().items()
|
||||
map.sort()
|
||||
|
||||
print u"Déconnexion…".encode(coding)
|
||||
|
||||
baie.logout()
|
||||
|
||||
print u"Enregistrement des informations…".encode(coding)
|
||||
|
||||
f = open(map_file, "w")
|
||||
f.write((u"""\
|
||||
# /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Fichier de mapping lun -> nom de volume
|
||||
#
|
||||
# Ce fichier est généré par %s
|
||||
|
||||
map = {
|
||||
""" % (sys.argv[0], baie)).encode(coding))
|
||||
|
||||
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"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print """\
|
||||
Usage : get_volume_mapping.py baie
|
||||
|
||||
Récupère le volume mapping sur la baie de disques choisie.
|
||||
"""
|
||||
else:
|
||||
get_mapping(sys.argv[1])
|
Loading…
Add table
Add a link
Reference in a new issue