Adam Litke has uploaded a new change for review.
Change subject: storage: Factor out getAllVolumes ......................................................................
storage: Factor out getAllVolumes
The SDM garbage collector needs to a mapping of volumes by imageID. Factor out this logic from getAllVolumes so it can be reused later.
Change-Id: If8c55edf6416dddc4a4f30b91422b3e968df2b99 Signed-off-by: Adam Litke alitke@redhat.com --- M vdsm/storage/fileSD.py 1 file changed, 17 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/40377/1
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py index 1220939..042f836 100644 --- a/vdsm/storage/fileSD.py +++ b/vdsm/storage/fileSD.py @@ -18,7 +18,6 @@ # Refer to the README and COPYING files for full details of the license #
-import collections import os import errno import logging @@ -405,6 +404,21 @@ """ pass
+ def getImageToVolumesMap(self): + volMetaPattern = os.path.join(self.mountpoint, self.sdUUID, + sd.DOMAIN_IMAGES, "*", "*.meta") + volMetaPaths = self.oop.glob.glob(volMetaPattern) + images = {} + for metaPath in volMetaPaths: + head, tail = os.path.split(metaPath) + volUUID, volExt = os.path.splitext(tail) + imgUUID = os.path.basename(head) + try: + images[imgUUID].append(volUUID) + except KeyError: + images[imgUUID] = [volUUID] + return images + def getAllVolumes(self): """ Return dict {volUUID: ((imgUUIDs,), parentUUID)} of the domain. @@ -422,17 +436,8 @@ Template volumes have no parent, and thus we report BLANK_UUID as their parentUUID. """ - volMetaPattern = os.path.join(self.mountpoint, self.sdUUID, - sd.DOMAIN_IMAGES, "*", "*.meta") - volMetaPaths = self.oop.glob.glob(volMetaPattern) - - # First create mapping from images to volumes - images = collections.defaultdict(list) - for metaPath in volMetaPaths: - head, tail = os.path.split(metaPath) - volUUID, volExt = os.path.splitext(tail) - imgUUID = os.path.basename(head) - images[imgUUID].append(volUUID) + # First get the mapping from images to volumes + images = self.getImageToVolumesMap()
# Using images to volumes mapping, we can create volumes to images # mapping, detecting template volumes and template images, based on
oVirt Jenkins CI Server has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 1:
Build Started (1/2) -> http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18313/
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 1:
Build Started (2/2) -> http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1543/
oVirt Jenkins CI Server has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/18313/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/1543/ : SUCCESS
Nir Soffer has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/40377/1/vdsm/storage/fileSD.py File vdsm/storage/fileSD.py:
Line 415: imgUUID = os.path.basename(head) Line 416: try: Line 417: images[imgUUID].append(volUUID) Line 418: except KeyError: Line 419: images[imgUUID] = [volUUID] Why did you replace defaultdict with regular dict? Line 420: return images Line 421: Line 422: def getAllVolumes(self): Line 423: """
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Nir Soffer has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 4: Code-Review-1
(1 comment)
-1 for visibility
https://gerrit.ovirt.org/#/c/40377/4/vdsm/storage/fileSD.py File vdsm/storage/fileSD.py:
Line 227: volMetaPattern = os.path.join(self.mountpoint, self.sdUUID, Line 228: sd.DOMAIN_IMAGES, "*", "*.meta") Line 229: volMetaPaths = self.oop.glob.glob(volMetaPattern) Line 230: Line 231: # First create mapping from images to volumes This comment is not relevant now, there is no second step here. Line 232: images = collections.defaultdict(list) Line 233: for metaPath in volMetaPaths: Line 234: head, tail = os.path.split(metaPath) Line 235: volUUID, volExt = os.path.splitext(tail)
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 9:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 11:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Jenkins CI RO has abandoned this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Abandoned
Abandoned due to no activity - please restore if still relevant
gerrit-hooks has posted comments on this change.
Change subject: storage: Factor out getAllVolumes ......................................................................
Patch Set 11:
* Update tracker: IGNORE, no Bug-Url found
vdsm-patches@lists.fedorahosted.org