Ala Hino has uploaded a new change for review.
Change subject: gluster:refactor: Refactor GlusterFSConnection class
......................................................................
gluster:refactor: Refactor GlusterFSConnection class
Gluster volume info is required when validating that gluster volume
is replica 3 and when calculating gluster backup servers option.
volinfo property introduced to save multiple calls to get gluster
volume info.
Change-Id: Ieb2e9d224fb1ad9acff6e9a77157851460d29a89
Signed-off-by: Ala Hino <ahino(a)redhat.com>
---
M vdsm/storage/storageServer.py
1 file changed, 15 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/42940/1
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 5ced157..43b2737 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -291,21 +291,23 @@
vfsType=vfsType,
options=options,
mountClass=mountClass)
- self._backup_servers_option = None
self._volfileServer, volname = self._remotePath.split(":", 1)
self._volname = volname.strip('/')
+ self._volinfo = None
@property
def options(self):
- if self._backup_servers_option is None:
- self._backup_servers_option = self._get_backup_servers_option()
- return ",".join(
- p for p in (self._options, self._backup_servers_option) if p)
+ backup_servers_option = self._get_backup_servers_option()
+ return ",".join(p for p in (self._options, backup_servers_option) if
p)
+
+ @property
+ def volinfo(self):
+ if self._volinfo is None:
+ self._volinfo = self._get_gluster_volinfo()
+ return self._volinfo
def validate(self):
- volinfo = supervdsm.getProxy().glusterVolumeInfo(self._volname,
- self._volfileServer)
- replicaCount = volinfo[self._volname]['replicaCount']
+ replicaCount = self.volinfo[self._volname]['replicaCount']
if replicaCount not in self.ALLOWED_REPLICA_COUNTS:
raise se.UnsupportedGlusterVolumeReplicaCountError(replicaCount)
@@ -314,16 +316,18 @@
self.log.warn("Using user specified backup-volfile-servers
option")
return ""
- volinfo = supervdsm.getProxy().glusterVolumeInfo(self._volname,
- self._volfileServer)
servers = [brick.split(":")[0]
- for brick in volinfo[self._volname]['bricks']]
+ for brick in self.volinfo[self._volname]['bricks']]
servers.remove(self._volfileServer)
if not servers:
return ""
return "backup-volfile-servers=" + ":".join(servers)
+ def _get_gluster_volinfo(self):
+ return supervdsm.getProxy().glusterVolumeInfo(self._volname,
+ self._volfileServer)
+
class NFSConnection(object):
DEFAULT_OPTIONS = ["soft", "nosharecache"]
--
To view, visit
https://gerrit.ovirt.org/42940
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb2e9d224fb1ad9acff6e9a77157851460d29a89
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino <ahino(a)redhat.com>