Change in vdsm[master]: gluster: Refactor GlusterFSConnection class

2015-05-06 Thread nsoffer
Nir Soffer has posted comments on this change.

Change subject: gluster: Refactor GlusterFSConnection class
..


Patch Set 3:

(4 comments)

https://gerrit.ovirt.org/#/c/40575/3/vdsm/storage/storageServer.py
File vdsm/storage/storageServer.py:

Line 166
Line 167
Line 168
Line 169
Line 170
Previously, we use to create the local path by:

os.path.join(self.getLocalpathBase(), remote_path)

And we customized the behavior by overriding self.getLocalpathBase(), accessing 
MountConnection.getLocalPathBase()

We also have code to customize MountConnection.localPathBase during runtime,
I don't see any need to support this.

We used the term "localPath" instead of the more common term "mountpoint".

This is clumsy and more complicated than needed. We can use this instead:

class MountConnection(object):

ROOT = "/tmp"
DIR = ""

Subclass can customized by overriding DIR.


Line 199
Line 200
Line 201
Line 202
Line 203
Use:

path = self._remotePath.replace("_", "__").replace("/", "_")
return os.path.join(self.ROOT, self.DIR, path)


Line 200: 
Line 201: def _getLocalPath(self):
Line 202: localPath = self.getLocalPathBase()
Line 203: if self._localPath:
Line 204: localPath = self._localPath
Not needed
Line 205: 
Line 206: return os.path.join(localPath,
Line 207: self._remotePath.replace("_",
Line 208:  
"__").replace("/", "_"))


Line 258: def __hash__(self):
Line 259: return hash(type(self)) ^ hash(self._mount)
Line 260: 
Line 261: 
Line 262: class GlusterFSConnection(object):
Generally I prefer composition over sub-classing, but in this case we don't 
have any behavior in the subclass, so creating an object using MountConnection 
is wasted effort.

The only differences between MountConnection and GlusterfsConnection are
- "glusterSD" used  in the mountpoint
- "glusterfs" used for vfsType

So a better change would be:

GlusterFSConnection(MountConnection):
VFSTYPE = "glusterfs"
DIR = "gluserSD"

And change MountConnection to use this class constants - see the comments in 
MountConnection.

The other change planed is to modify options before connecting. We can
override the options property in the subclass, and return a modified 
self._options.
Line 263: 
Line 264: def __init__(self, spec, vfsType="glusterfs", options=""):
Line 265: self._vfsType = vfsType
Line 266: self._remotePath = spec


-- 
To view, visit https://gerrit.ovirt.org/40575
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino 
Gerrit-Reviewer: Allon Mureinik 
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer 
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: Yes
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: gluster: Refactor GlusterFSConnection class

2015-05-06 Thread automation
automat...@ovirt.org has posted comments on this change.

Change subject: gluster: Refactor GlusterFSConnection class
..


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'])

-- 
To view, visit https://gerrit.ovirt.org/40575
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino 
Gerrit-Reviewer: Allon Mureinik 
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer 
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: gluster: Refactor GlusterFSConnection class

2015-05-06 Thread automation
automat...@ovirt.org has posted comments on this change.

Change subject: gluster: Refactor GlusterFSConnection class
..


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'])

-- 
To view, visit https://gerrit.ovirt.org/40575
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino 
Gerrit-Reviewer: Allon Mureinik 
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer 
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: gluster: Refactor GlusterFSConnection class

2015-05-06 Thread ahino
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/117
Signed-off-by: Ala Hino 
---
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 
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: gluster: Refactor GlusterFSConnection class

2015-05-06 Thread automation
automat...@ovirt.org has posted comments on this change.

Change subject: gluster: Refactor GlusterFSConnection class
..


Patch Set 1:

* Update tracker::#117::OK
* Check Bug-Url::OK
* Check Public Bug::#117::OK, public bug
* Check Product::#117::OK, Correct product oVirt
* Check TR::SKIP, not in a monitored branch (ovirt-3.5 ovirt-3.4 ovirt-3.3 
ovirt-3.2)
* Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 
'ovirt-3.4', 'ovirt-3.3'])

-- 
To view, visit https://gerrit.ovirt.org/40575
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2a55a7f219a60c7ffb0ce981175492e560bb757f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino 
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches