Ala Hino has uploaded a new change for review. Change subject: gluster: Refactor GlusterFSConnection class ......................................................................
gluster: Refactor GlusterFSConnection class Refactor GlusterFSConnection class to delegate calls to MountConnection instead of inheriting it. Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f Bug-Url: https://bugzilla.redhat.com/1177777 Signed-off-by: Ala Hino <ah...@redhat.com> --- M vdsm/storage/storageServer.py 1 file changed, 67 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/40575/1 diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py index 50fcf5c..e198846 100644 --- a/vdsm/storage/storageServer.py +++ b/vdsm/storage/storageServer.py @@ -191,14 +191,19 @@ def getLocalPathBase(cls): return cls.localPathBase - def __init__(self, spec, vfsType=None, options=""): + def __init__(self, spec, vfsType=None, options="", localPath=None): self._vfsType = vfsType self._remotePath = spec self._options = options + self._localPath = localPath self._mount = mount.Mount(spec, self._getLocalPath()) def _getLocalPath(self): - return os.path.join(self.getLocalPathBase(), + localPath = self.getLocalPathBase() + if self._localPath: + localPath = self._localPath + + return os.path.join(localPath, self._remotePath.replace("_", "__").replace("/", "_")) @@ -254,10 +259,67 @@ return hash(type(self)) ^ hash(self._mount) -class GlusterFSConnection(MountConnection): +class GlusterFSConnection(object): - def getLocalPathBase(cls): - return os.path.join(MountConnection.getLocalPathBase(), "glusterSD") + def __init__(self, spec, vfsType="glusterfs", options=""): + self._vfsType = vfsType + self._remotePath = spec + self._options = options + + def connect(self): + localPath = os.path.join(MountConnection. + getLocalPathBase(), + "glusterSD" + ) + mountCon = MountConnection(self._remotePath, + "glusterfs", + self._options, + localPath + ) + return mountCon.connect() + + def isConnected(self): + localPath = os.path.join(MountConnection. + getLocalPathBase(), + "glusterSD" + ) + mountCon = MountConnection(self._remotePath, + "glusterfs", + self._options, + localPath + ) + return mountCon.isConnected() + + def disconnect(self): + localPath = os.path.join(MountConnection. + getLocalPathBase(), + "glusterSD" + ) + mountCon = MountConnection(self._remotePath, + "glusterfs", + self._options, + localPath + ) + return mountCon.disconnect() + + def __eq__(self, other): + if not isinstance(other, GlusterFSConnection): + return False + + try: + return (other._vfsType == self._vfsType and + other._remotePath == self._remotePath and + other._options == self._options + ) + except Exception: + return False + + def __hash__(self): + hsh = hash(type(self)) + hsh ^= hash(self._vfsType) + hsh ^= hash(self._remotePath) + hsh ^= hash(self._options) + return hsh class NFSConnection(object): -- To view, visit https://gerrit.ovirt.org/40575 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ala Hino <ah...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches