Change in vdsm[master]: storage.glusterVolume.getVmVolInfo: move logic to storage do...

danken at redhat.com danken at redhat.com
Mon Nov 11 09:52:12 UTC 2013


Dan Kenigsberg has uploaded a new change for review.

Change subject: storage.glusterVolume.getVmVolInfo: move logic to storage domain
......................................................................

storage.glusterVolume.getVmVolInfo: move logic to storage domain

volume.getVmVolInfo is never used. The only usage of
glusterVolume.getVmVolInfo requires a cumbersome production of a
glusterVolume object. This patch moves the logic into the storage
domain, and enable the complete removal of glusterVolume in a subsequent
patch.

Change-Id: I05352ee60546f03b8e6272abbdd923d0ec6074b7
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/storage/glusterSD.py
M vdsm/storage/glusterVolume.py
M vdsm/storage/hsm.py
M vdsm/storage/sd.py
M vdsm/storage/volume.py
5 files changed, 39 insertions(+), 66 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/21122/1

diff --git a/vdsm/storage/glusterSD.py b/vdsm/storage/glusterSD.py
index 2931083..492413f 100644
--- a/vdsm/storage/glusterSD.py
+++ b/vdsm/storage/glusterSD.py
@@ -5,6 +5,8 @@
 import fileSD
 import mount
 import storage_exception as se
+import supervdsm
+from gluster.exception import GlusterException
 
 
 class GlusterStorageDomain(nfsSD.NfsStorageDomain):
@@ -27,6 +29,39 @@
 
         raise se.StorageDomainDoesNotExist(sdUUID)
 
+    def getExtraVolumeInfo(self, volPath):
+        volfileServer, gvolname = self.getRemotePath().rsplit(":", 1)
+
+        # Volume transport to Libvirt transport mapping
+        VOLUME_TRANS_MAP = {'TCP': 'tcp', 'RDMA': 'rdma'}
+
+        # Extract the volume's transport using gluster cli
+        svdsmProxy = supervdsm.getProxy()
+        try:
+            volInfo = svdsmProxy.glusterVolumeInfo(gvolname, volfileServer)
+            volTrans = VOLUME_TRANS_MAP[volInfo[gvolname]['transportType'][0]]
+        except GlusterException:
+            # In case of issues with finding transport type, default to tcp
+            self.log.warning("Unable to find transport type for GlusterFS"
+                             " volume %s. GlusterFS server = %s."
+                             "Defaulting to tcp",
+                             (gvolname, volfileServer), exc_info=True)
+            volTrans = VOLUME_TRANS_MAP['TCP']
+
+        # Use default port
+        volPort = "0"
+
+        # sdUUID/images/imgUUID/volUUID
+        imgFileRelPath = '/'.join(volPath.rsplit("/")[-4:])
+
+        glusterPath = gvolname + '/' + imgFileRelPath
+
+        return {'path': glusterPath,
+                'protocol': 'gluster', 'volPort': volPort,
+                'volTransport': volTrans,
+                'volfileServer': volfileServer,
+                'volType': 'network',
+                }
 
 def findDomain(sdUUID):
     return GlusterStorageDomain(GlusterStorageDomain.findDomainPath(sdUUID))
diff --git a/vdsm/storage/glusterVolume.py b/vdsm/storage/glusterVolume.py
index 3368de3..1406cdd 100644
--- a/vdsm/storage/glusterVolume.py
+++ b/vdsm/storage/glusterVolume.py
@@ -1,8 +1,4 @@
-from volume import VmVolumeInfo
 import fileVolume
-from sdc import sdCache
-import supervdsm as svdsm
-from gluster.exception import GlusterException
 
 
 class GlusterVolume(fileVolume.FileVolume):
@@ -11,44 +7,3 @@
         fileVolume.FileVolume.__init__(self, repoPath, sdUUID, imgUUID,
                                        volUUID)
 
-    def getVmVolumeInfo(self):
-        """
-        Send info to represent Gluster volume as a network block device
-        """
-        rpath = sdCache.produce(self.sdUUID).getRemotePath()
-        rpath_list = rpath.rsplit(":", 1)
-        volfileServer = rpath_list[0]
-        volname = rpath_list[1]
-
-        # Volume transport to Libvirt transport mapping
-        VOLUME_TRANS_MAP = {'TCP': 'tcp', 'RDMA': 'rdma'}
-
-        # Extract the volume's transport using gluster cli
-        svdsmProxy = svdsm.getProxy()
-
-        try:
-            volInfo = svdsmProxy.glusterVolumeInfo(volname, volfileServer)
-            volTrans = VOLUME_TRANS_MAP[volInfo[volname]['transportType'][0]]
-        except GlusterException:
-            # In case of issues with finding transport type, default to tcp
-            self.log.warning("Unable to find transport type for GlusterFS"
-                             " volume %s. GlusterFS server = %s."
-                             "Defaulting to tcp",
-                             (volname, volfileServer), exc_info=True)
-            volTrans = VOLUME_TRANS_MAP['TCP']
-
-        # Use default port
-        volPort = "0"
-
-        imgFilePath = self.getVolumePath()
-        imgFilePath_list = imgFilePath.rsplit("/")
-
-        # Extract path to the image, relative to the gluster mount
-        imgFileRelPath = "/".join(imgFilePath_list[-4:])
-
-        glusterPath = volname + '/' + imgFileRelPath
-
-        return {'volType': VmVolumeInfo.TYPE_NETWORK, 'path': glusterPath,
-                'protocol': 'gluster', 'volPort': volPort,
-                'volTransport': volTrans,
-                'volfileServer': volfileServer}
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 15fd9fa..1829a76 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3294,12 +3294,7 @@
 
             imgVolumesInfo.append(volInfo)
 
-        if isinstance(dom.getRealDomain(), glusterSD.GlusterStorageDomain):
-            ginfo = dom.produceVolume(imgUUID, volUUID).getVmVolumeInfo()
-        else:
-            ginfo = {'volType': 'path'}
-
-        return {'path': leafPath, 'info': ginfo,
+        return {'path': leafPath, 'info': dom.getExtraVolumeInfo(leafPath),
                 'imgVolumesInfo': imgVolumesInfo}
 
     @public
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 3249343..31759df 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -782,3 +782,6 @@
         (on NFS mostly) due to lazy file removal
         """
         pass
+
+    def getExtraVolumeInfo(self, volPath):
+        return {'volType': 'path'}
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index fc7a3e5..1149d72 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -117,11 +117,6 @@
     return None
 
 
-class VmVolumeInfo(object):
-    TYPE_PATH = "path"
-    TYPE_NETWORK = "network"
-
-
 class Volume(object):
     log = logging.getLogger('Storage.Volume')
 
@@ -926,16 +921,6 @@
         if not self.volumePath:
             raise se.VolumeAccessError(self.volUUID)
         return self.volumePath
-
-    def getVmVolumeInfo(self):
-        """
-        Get volume path/info as dict.
-        Derived classes can use this if they want to represent the
-        volume to the VM in a different way than the standard 'path' way.
-        """
-        # By default, send path
-        return {'volType': VmVolumeInfo.TYPE_PATH,
-                'path': self.getVolumePath()}
 
     def getMetaParam(self, key):
         """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05352ee60546f03b8e6272abbdd923d0ec6074b7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list