New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/874
commit 3dce6a11fb181de12a242e92b6b7b74edbb79d78
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Wed Aug 24 22:06:43 2011 +0300
BZ#732416 - Pluralise lvm remove LV(s) verb.
Change-Id: Idbf76445d98dc5b80790f1a54c02f7029f476f65
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 0b8bc5a..26a5a12 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -714,7 +714,7 @@ class BlockStorageDomain(sd.StorageDomain):
for lv in lvs:
#Fix me: Should raise and get resource lock.
try:
- lvm.removeLV(sdUUID, lv.name)
+ lvm.removeLVs(sdUUID, lv.name)
except se.CannotRemoveLogicalVolume, e:
cls.log.warning("Remove logical volume failed %s/%s %s",
sdUUID, lv.name, str(e))
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 25ec92c..a4c61f1 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -86,7 +86,7 @@ class BlockVolume(volume.Volume):
try:
#Fix me: assert resource lock.
lvm.getLV(sdUUID, volUUID)
- lvm.removeLV(sdUUID, volUUID)
+ lvm.removeLVs(sdUUID, volUUID)
except se.LogicalVolumeDoesNotExistError, e:
pass #It's OK: inexistent LV, don't try to remove.
except se.CannotRemoveLogicalVolume, e:
@@ -298,7 +298,7 @@ class BlockVolume(volume.Volume):
try:
try:
- lvm.removeLV(self.sdUUID, self.volUUID)
+ lvm.removeLVs(self.sdUUID, self.volUUID)
except se.CannotRemoveLogicalVolume:
# At this point LV is already marked as illegal, we will try to cleanup
whatever we can...
pass
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index ca90329..1760408 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -979,29 +979,35 @@ def createLV(vgName, lvName, size, activate=True, contiguous=False,
initialTag=N
_setLVAvailability(vgName, lvName, "n")
-def removeLV(vgName, lvName):
- #Assert that the LV is inactive before remove.
- if os.path.exists(lvPath(vgName, lvName)):
- #Fix me
- #Should not remove active LVs
- #raise se.CannotRemoveLogicalVolume(vgName, lvName)
- log.warning("Removing active volume %s/%s" % (vgName, lvName))
+def removeLVs(vgName, lvNames):
+ lvNames = _normalizeargs(lvNames)
+ #Assert that the LVs are inactive before remove.
+ for lvName in lvNames:
+ if os.path.exists(lvPath(vgName, lvName)):
+ #Fix me
+ #Should not remove active LVs
+ #raise se.CannotRemoveLogicalVolume(vgName, lvName)
+ log.warning("Removing active volume %s/%s" % (vgName, lvName))
#LV exists or not in cache, attempting to remove it.
#Removing Stubs also. Active Stubs should raise.
# Destroy LV
#Fix me:removes active LVs too. "-f" should be removed.
- cmd = ("lvremove", "-f") + LVM_NOBACKUP + ("%s/%s" %
(vgName, lvName),)
+ cmd = ["lvremove", "-f"]
+ cmd.extend(LVM_NOBACKUP)
+ for lvName in lvNames:
+ cmd.append("%s/%s" % (vgName, lvName))
rc, out, err = _lvminfo.cmd(cmd)
if rc == 0:
- # Remove the LV from the cache
- _lvminfo._lvs.pop((vgName, lvName), None)
- # If lvremove succeeded it affected VG as well
- _lvminfo._invalidatevgs(vgName)
+ for lvName in lvNames:
+ # Remove the LV from the cache
+ _lvminfo._lvs.pop((vgName, lvName), None)
+ # If lvremove succeeded it affected VG as well
+ _lvminfo._invalidatevgs(vgName)
else:
# Otherwise LV info needs to be refreshed
_lvminfo._invalidatelvs(vgName, lvName)
- raise se.CannotRemoveLogicalVolume(vgName, lvName)
+ raise se.CannotRemoveLogicalVolume(vgName, str(lvNames))
def extendLV(vgName, lvName, size):