Change in vdsm[master]: lvm: Remove args hack for activateLVs and deactivateLVs
alitke at redhat.com
alitke at redhat.com
Thu Apr 7 19:50:46 UTC 2016
Adam Litke has uploaded a new change for review.
Change subject: lvm: Remove args hack for activateLVs and deactivateLVs
......................................................................
lvm: Remove args hack for activateLVs and deactivateLVs
In order to support calling these functions with either a single LV or a
list of LVs a hack called _normalizeArgs is being used. The pythonic
way to do this is by using *lvNames in the argument list to indicate
that we expect a variable number of positional arguments.
Change-Id: I5f23f5b21217373bd79abdcfe3d4f8cf233b9e90
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M tests/storagefakelib.py
M tests/storagefakelibTests.py
M vdsm/storage/blockSD.py
M vdsm/storage/lvm.py
M vdsm/storage/resourceFactories.py
5 files changed, 12 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/55846/1
diff --git a/tests/storagefakelib.py b/tests/storagefakelib.py
index 6424fbf..e94cb23 100644
--- a/tests/storagefakelib.py
+++ b/tests/storagefakelib.py
@@ -133,7 +133,7 @@
self.lvmd[(vgName, lvName)] = lv_md
self.vgmd[vgName]['lv_count'] = str(lv_count)
- def activateLVs(self, vgName, lvNames):
+ def activateLVs(self, vgName, *lvNames):
for lv in lvNames:
try:
lv_md = self.lvmd[(vgName, lv)]
diff --git a/tests/storagefakelibTests.py b/tests/storagefakelibTests.py
index 4456009..6a87972 100644
--- a/tests/storagefakelibTests.py
+++ b/tests/storagefakelibTests.py
@@ -272,7 +272,7 @@
with self.base_config() as lvm:
lvm.createLV(self.VG_NAME, self.LV_NAME, str(self.LV_SIZE_MB),
activate=False)
- lvm.activateLVs(self.VG_NAME, [self.LV_NAME])
+ lvm.activateLVs(self.VG_NAME, self.LV_NAME)
lv = lvm.getLV(self.VG_NAME, self.LV_NAME)
self.assertTrue(lv.active)
self.assertEqual('a', lv.attr.state)
@@ -299,7 +299,7 @@
@permutations([
[se.VolumeGroupDoesNotExist, 'getVG', ['vg']],
- [se.CannotActivateLogicalVolume, 'activateLVs', ['vg', ['lv']]],
+ [se.CannotActivateLogicalVolume, 'activateLVs', ['vg', 'lv']],
[se.MissingTagOnLogicalVolume, 'addtag', ['vg', 'lv', 'tag']],
[se.CannotCreateLogicalVolume, 'createLV', ['vg', 'lv', '1024']],
[se.LogicalVolumeDoesNotExistError, 'getLV', ['vg', 'lv']],
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index e2b2f96..5745f4a 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -455,12 +455,12 @@
def getLeasesFilePath(self):
# TODO: Determine the path without activating the LV
- lvm.activateLVs(self.sdUUID, [sd.LEASES])
+ lvm.activateLVs(self.sdUUID, sd.LEASES)
return lvm.lvPath(self.sdUUID, sd.LEASES)
def getIdsFilePath(self):
# TODO: Determine the path without activating the LV
- lvm.activateLVs(self.sdUUID, [sd.IDS])
+ lvm.activateLVs(self.sdUUID, sd.IDS)
return lvm.lvPath(self.sdUUID, sd.IDS)
def extendVolume(self, volumeUUID, size, isShuttingDown=None):
@@ -697,7 +697,7 @@
domMD = os.path.join(self.domaindir, sd.DOMAIN_META_DATA)
fileUtils.createdir(domMD)
- lvm.activateLVs(self.sdUUID, SPECIAL_LVS)
+ lvm.activateLVs(self.sdUUID, *SPECIAL_LVS)
for lvName in SPECIAL_LVS:
dst = os.path.join(domMD, lvName)
if not os.path.lexists(dst):
@@ -807,7 +807,7 @@
def __init__(self, sdUUID):
manifest = self.manifestClass(sdUUID)
sd.StorageDomain.__init__(self, manifest)
- lvm.activateLVs(self.sdUUID, SPECIAL_LVS)
+ lvm.activateLVs(self.sdUUID, *SPECIAL_LVS)
self.metavol = lvm.lvPath(self.sdUUID, sd.METADATA)
# Check that all devices in the VG have the same logical and physical
@@ -1126,7 +1126,7 @@
self.removeImageLinks(imgUUID)
allVols = self.getAllVolumes()
volUUIDs = self._manifest._getImgExclusiveVols(imgUUID, allVols)
- lvm.deactivateLVs(self.sdUUID, volUUIDs)
+ lvm.deactivateLVs(self.sdUUID, *volUUIDs)
def linkBCImage(self, imgPath, imgUUID):
dst = self.getLinkBCImagePath(imgUUID)
@@ -1196,7 +1196,7 @@
If the image is based on a template image it will be activated.
"""
- lvm.activateLVs(self.sdUUID, volUUIDs)
+ lvm.activateLVs(self.sdUUID, *volUUIDs)
vgDir = os.path.join("/dev", self.sdUUID)
return self.createImageLinks(vgDir, imgUUID, volUUIDs)
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index d8aec58..bcfd9ab 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -1184,16 +1184,14 @@
_resizeLV("lvreduce", vgName, lvName, size)
-def activateLVs(vgName, lvNames):
- lvNames = _normalizeargs(lvNames)
+def activateLVs(vgName, *lvNames):
toActivate = [lvName for lvName in lvNames
if not _isLVActive(vgName, lvName)]
if toActivate:
_setLVAvailability(vgName, toActivate, "y")
-def deactivateLVs(vgName, lvNames):
- lvNames = _normalizeargs(lvNames)
+def deactivateLVs(vgName, *lvNames):
toDeactivate = [lvName for lvName in lvNames
if _isLVActive(vgName, lvName)]
if toDeactivate:
diff --git a/vdsm/storage/resourceFactories.py b/vdsm/storage/resourceFactories.py
index 4e83492..39134ff 100644
--- a/vdsm/storage/resourceFactories.py
+++ b/vdsm/storage/resourceFactories.py
@@ -146,7 +146,7 @@
# TODO Fix resource framework to hold images, instead of specific vols.
# This assumes that chains can not spread into more than one SD.
if dom.__class__.__name__ == "BlockStorageDomain":
- lvm.activateLVs(self.sdUUID, volUUIDChain)
+ lvm.activateLVs(self.sdUUID, *volUUIDChain)
failed = False
# Acquire template locks:
--
To view, visit https://gerrit.ovirt.org/55846
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f23f5b21217373bd79abdcfe3d4f8cf233b9e90
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>
More information about the vdsm-patches
mailing list