Eduardo has uploaded a new change for review.

Change subject: Remove StoragePool.getImageDomainsList().
......................................................................

Remove StoragePool.getImageDomainsList().

Avoid code duplication.

Related to BZ#905038.

Change-Id: I225fa7a58e1fabb844cc883938e94df39d2a8ae2
Signed-off-by: Eduardo <[email protected]>
---
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
2 files changed, 11 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/12927/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index e8d3dbb..196862d 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3277,12 +3277,18 @@
         vars.task.getSharedLock(STORAGE, spUUID)
         pool = self.getPool(spUUID)
         # Find out domain list from the pool metadata
-        domList = sorted(pool.getDomains().keys())
-        for sdUUID in domList:
-            vars.task.getSharedLock(STORAGE, sdUUID)
+        activeDoms = sorted(pool.getDomains(activeOnly=True).keys())
+        foundIn = []
+        for sdUUID in activeDoms:
+            try:
+                imgs = self.getImagesList(sdUUID)
+            except se.StorageDomainDoesNotExist:
+                self.log.error("domain %s can't be reached.", exc_info=True)
+            else:
+                if imgUUID in imgs:
+                    foundIn.append(sdUUID)
 
-        domainslist = pool.getImageDomainsList(imgUUID=imgUUID)
-        return dict(domainslist=domainslist)
+        return dict(domainslist=foundIn)
 
     @public
     def prepareForShutdown(self, options=None):
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index b578175..dac9eb7 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1650,33 +1650,6 @@
                 dom.createMasterTree()
 
     @unsecured
-    def getImageDomainsList(self, imgUUID):
-        """
-        Get list of all domains in the pool that contain imgUUID
-         'imgUUID' - image UUID
-        """
-        # TODO: get rid of this verb and let management query each domain
-        #       separately the problem with current implementation is that when
-        #       a domain is not accessible the error must be ignored and
-        #       management can reach wrong conclusions.
-        domainsdict = self.getDomains(activeOnly=True)
-        domainslist = []
-
-        for sdUUID in domainsdict:
-            try:
-                d = sdCache.produce(sdUUID)
-            except Exception:
-                # Pass over invisible active domains
-                self.log.error("Unexpected error", exc_info=True)
-                continue
-
-            imageslist = d.getAllImages()
-            if imgUUID in imageslist:
-                domainslist.append(sdUUID)
-
-        return domainslist
-
-    @unsecured
     def isActive(self, sdUUID):
         return sdUUID in self.getDomains(activeOnly=True)
 


--
To view, visit http://gerrit.ovirt.org/12927
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I225fa7a58e1fabb844cc883938e94df39d2a8ae2
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

Reply via email to