diff --git a/gestion/iscsi/nolslib.py b/gestion/iscsi/nolslib.py index 90fc88bc..cf46c12b 100644 --- a/gestion/iscsi/nolslib.py +++ b/gestion/iscsi/nolslib.py @@ -25,6 +25,11 @@ password = "" # Récupère des identifiants execfile("/etc/crans/secrets/nols.py") +class NolsError(Exception): + def __init__(self, msg): + Exception.__init__(self, msg) + + class Nols(object): '''Objet représentant la baie de stockage''' @@ -84,6 +89,9 @@ class Nols(object): # Remplace les fins de ligne dos par des fin de lignes unix resp = crlf_regexp.sub("\n", resp) + if resp.lower().startswith("error"): + raise NolsError(resp.replace("Error: ", "")) + return resp def show(self, what): @@ -153,7 +161,7 @@ class Nols(object): while lun in map: lun = lun + 1 # Création du volume - self.cmd("create volume vdisk %s size %d%s lun %d %s" % (vdisk, size, unit, lun, name)) + result = self.cmd("create volume vdisk %s size %d%s lun %d %s" % (vdisk, size, unit, lun, name)) print "Le volume %s a été créé, son numéro d'identification est %d" %(name, lun)