Eduardo has uploaded a new change for review. Change subject: New getChildrenList implementation. ......................................................................
New getChildrenList implementation. Disclaimer: this function should be removed! This implementation returns children of any image on the SD. Avoids to produce each volume in the domain. Implemented like one shot operation. Change-Id: I584cd5d1b03d3965457f12c3d67de95455d1de24 Related-to: BZ#960952 Signed-off-by: Eduardo <[email protected]> --- M configure.ac M lib/vdsm/constants.py.in M lib/vdsm/utils.py M vdsm/storage/blockVolume.py M vdsm/storage/fileVolume.py M vdsm/storage/volume.py 6 files changed, 43 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/15765/1 diff --git a/configure.ac b/configure.ac index 265e3ab..45ea4df 100644 --- a/configure.ac +++ b/configure.ac @@ -171,6 +171,7 @@ AC_PATH_PROG([OPENSSL_PATH], [openssl], [/usr/bin/openssl]) AC_PATH_PROG([PERSIST_PATH], [persist], [/usr/sbin/persist]) AC_PATH_PROG([PGREP_PATH], [pgrep], [/usr/bin/pgrep]) +AC_PATH_PROG([GREP_PATH], [grep], [/usr/bin/grep]) AC_PATH_PROG([QEMUIMG_PATH], [qemu-img], [/usr/bin/qemu-img]) AC_PATH_PROG([REBOOT_PATH], [reboot], [/usr/bin/reboot]) AC_PATH_PROG([RPM_PATH], [rpm], [/bin/rpm]) diff --git a/lib/vdsm/constants.py.in b/lib/vdsm/constants.py.in index 63771f6..cfe0e9a 100644 --- a/lib/vdsm/constants.py.in +++ b/lib/vdsm/constants.py.in @@ -113,6 +113,7 @@ EXT_PERSIST = '@PERSIST_PATH@' EXT_PGREP = '@PGREP_PATH@' +EXT_GREP = '@GREP_PATH@' EXT_PYTHON = '@PYTHON@' EXT_QEMUIMG = '@QEMUIMG_PATH@' diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py index 4847a68..5fed076 100644 --- a/lib/vdsm/utils.py +++ b/lib/vdsm/utils.py @@ -150,6 +150,18 @@ time.sleep(0.1) +def grepCmd(pattern, path): + cmd = (constants.EXT_GREP, '-E', pattern, path) + rc, out, err = execCmd(cmd) + if rc == 0: + matches = out # A list of matching lines + elif rc == 1: + matches = [] # pattern not found + else: + raise ValueError("rc: %s, out: %s, err: %s" % (rc, out, err)) + return matches + + def forceLink(src, dst): """ Makes or replaces a hard link. diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 606762c..36cc014 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -480,6 +480,16 @@ lvs = lvm.lvsByTag(sdUUID, "%s%s" % (TAG_PREFIX_IMAGE, imgUUID)) return [lv.name for lv in lvs] + def getChildrenList(self): + """ Return the list of children volume UUIDs. + + Children can be found in any image of the volume SD. + TODO: Remove this function. + """ + lvs = lvm.lvsByTag(self.sdUUID, + "%s%s" % (TAG_PREFIX_PARENT, self.volUUID)) + return [lv.name for lv in lvs] + def removeMetadata(self, metaId): """ Just wipe meta. diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py index 8b0a33e..026ac39 100644 --- a/vdsm/storage/fileVolume.py +++ b/vdsm/storage/fileVolume.py @@ -367,6 +367,25 @@ volList.append(volid) return volList + def getChildrenList(self): + """ Return the list of children volume UUIDs. + + Children can be found in any image of the volume SD. + TODO: Remove this function. + """ + domPath = self.imagePath.split('images')[0] + gPath = os.path.join(domPath, 'images', '*', '*.meta') + pattern = "%s.*%s" % (volume.PUUID, self.volUUID) + matches = oop.getProcessPool(self.sdUUID).utils.grepCmd(pattern, gPath) + if matches: + children = [] + for line in matches: + children.append(line.split('=')[1]) + else: + children = [] + + return children + @classmethod def newVolumeLease(cls, metaId, sdUUID, volUUID): cls.log.debug("Initializing volume lease volUUID=%s sdUUID=%s, " diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index 1c81d87..a088bfb 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -830,19 +830,6 @@ self.sdUUID, self.imgUUID, self.volUUID, str(info)) return info - def getChildrenList(self): - """ - Fetch the list of children volumes (in single image) - """ - vols = self.getImageVolumes(self.repoPath, self.sdUUID, self.imgUUID) - children = [] - dom = sdCache.produce(self.sdUUID) - for v in vols: - if (dom.produceVolume(self.imgUUID, v).getParent() == - self.volUUID): - children.append(v) - return children - def getParentVolume(self): """ Return parent volume object -- To view, visit http://gerrit.ovirt.org/15765 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I584cd5d1b03d3965457f12c3d67de95455d1de24 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
