Eduardo has uploaded a new change for review. Change subject: Pluralize lvm.changelv(). ......................................................................
Pluralize lvm.changelv(). Allow changing multiple attributes at once. Change-Id: I22c4ef83f23c0004a5a1e6a8a7e55d13b56c4f50 Signed-off-by: Eduardo <[email protected]> --- M vdsm/storage/blockVolume.py M vdsm/storage/lvm.py 2 files changed, 17 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/8289/1 diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 38285c1..98c471b 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -647,7 +647,7 @@ lvNames = tuple(vol.volUUID for vol in volumes) #Assert volumes are writable. (Don't do this at home.) try: - lvm.changelv(sdUUID, lvNames, "--permission", "rw") + lvm.changelv(sdUUID, lvNames, ("--permission", "rw")) except se.StorageException, e: # Hope this only means that some volumes were already writable. pass diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py index 13cf4cf..e904431 100644 --- a/vdsm/storage/lvm.py +++ b/vdsm/storage/lvm.py @@ -725,15 +725,24 @@ "vgchange on vg(s) %s failed. %d %s %s" % (vgs, rc, out, err)) -def changelv(vg, lvs, attrName, attrValue): - # Note: - # You may activate an activated LV without error - # but lvchange returns an error (RC=5) when activating rw if already rw +def changelv(vg, lvs, attrs): + """ + Change multiple attributes on a multiple LVs. + + vg: VG name + lvs: a single LV name or LV names iterable. + attrs: a (attr, value) tuple or a tuple of (attr, value) tuples. + + Note: + You may activate an activated LV without error + but lvchange returns an error (RC=5) when activating rw if already rw + """ + lvs = _normalizeargs(lvs) # If it fails or not we (may be) change the lv, # so we invalidate cache to reload these volumes on first occasion lvnames = tuple("%s/%s" % (vg, lv) for lv in lvs) - cmd = ("lvchange",) + LVM_NOBACKUP + (attrName, attrValue) + lvnames + cmd = ("lvchange",) + LVM_NOBACKUP + attrs + lvnames rc, out, err = _lvminfo.cmd(cmd) _lvminfo._invalidatelvs(vg, lvs) if rc != 0 and len(out) < 1: @@ -742,7 +751,7 @@ def _setLVAvailability(vg, lvs, available): try: - changelv(vg, lvs, "--available", available) + changelv(vg, lvs, ("--available", available)) except se.StorageException, e: error = ({"y": se.CannotActivateLogicalVolumes, "n": se.CannotDeactivateLogicalVolume} @@ -1230,7 +1239,7 @@ def setrwLV(vg, lv, rw=True): permission = {False: 'r', True: 'rw'}[rw] try: - changelv(vg, lv, "--permission", permission) + changelv(vg, lv, ("--permission", permission)) except se.StorageException: l = getLV(vg, lv) if l.writeable == rw: -- To view, visit http://gerrit.ovirt.org/8289 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I22c4ef83f23c0004a5a1e6a8a7e55d13b56c4f50 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Eduardo <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
