[gestion/iscsi/slonlib] plus de commandes
darcs-hash:20081219035429-c41ad-eebbbfd2bb2c570384b9725fc32d7cbc1de66f23.gz
This commit is contained in:
parent
29b7c931fe
commit
20cd3b5b23
1 changed files with 31 additions and 0 deletions
|
@ -92,6 +92,14 @@ class Slon:
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
def show(self, what):
|
||||||
|
u'''Raccourci pour: print slon.cmd("show <what>")'''
|
||||||
|
print self.cmd("show " + what)
|
||||||
|
|
||||||
|
def help(self, what):
|
||||||
|
u'''Raccourci pour: print slon.cmd("help <what>")'''
|
||||||
|
print self.cmd("help " + what)
|
||||||
|
|
||||||
def volume_map(self):
|
def volume_map(self):
|
||||||
u'''Retourne le mapping lun<->nom de volume'''
|
u'''Retourne le mapping lun<->nom de volume'''
|
||||||
map = {}
|
map = {}
|
||||||
|
@ -99,3 +107,26 @@ class Slon:
|
||||||
map[int(m.group(2))] = m.group(1)
|
map[int(m.group(2))] = m.group(1)
|
||||||
return map
|
return map
|
||||||
|
|
||||||
|
def create_volume(self, name, size, unit="GB", vdisk="slon1"):
|
||||||
|
u'''Créé un nouveau volume. Retourne le lun sur lequel il est
|
||||||
|
mappé. La taille est en Giga-octet. L'unité doit être "KB",
|
||||||
|
"MB" ou "GB". Par défault c'est "GB".'''
|
||||||
|
|
||||||
|
# Création du volume
|
||||||
|
self.cmd("create volume vdisk %s size %d%s %s" % (vdisk, size, unit, name))
|
||||||
|
|
||||||
|
# On récupère le mapping pour chercher un lun de libre
|
||||||
|
map = self.volume_map()
|
||||||
|
|
||||||
|
lun = 0
|
||||||
|
while lun in map: lun = lun + 1
|
||||||
|
|
||||||
|
# Mapping du volume
|
||||||
|
self.cmd("map volume %s lun %d" % (name, lun))
|
||||||
|
|
||||||
|
return lun
|
||||||
|
|
||||||
|
def delete_volume(self, name):
|
||||||
|
u'''Supprime un volume'''
|
||||||
|
|
||||||
|
self.cmd("delete volume %s")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue