Darshan N has uploaded a new change for review.
Change subject: gluster: geo-replication configuration related verbs.
......................................................................
gluster: geo-replication configuration related verbs.
This patch adds four verbs related to geo-replication
configuration.
Verbs:
* glusterVolumeGeoRepConfigList
- Lists all the configuration for the session.
Returns:
{georepConfig:[{'configName': configuration name,
'description': value}]}
* glusterVolumeGeoRepConfigGet
- Gives the configuration value for a specified
configuration.
Returns:
{georepConfig:{'configName': configuration name,
'description': value}}
* glusterVolumeGeoRepConfigSet
- Sets the configuration value for a given
configuration.
Returns:bool
* glusterVolumeGeoRepConfigSetDefault
- Sets the configuration to its default value
Returns:bool
Change-Id: Ifee571dbf3c56633e415d32f8d518cb64aaf1add
Signed-off-by: ndarshan <dnarayan(a)redhat.com>
---
M client/vdsClientGluster.py
M vdsm/gluster/api.py
M vdsm/gluster/cli.py
M vdsm/gluster/exception.py
M vdsm/gluster/vdsmapi-gluster-schema.json
5 files changed, 354 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/30162/1
diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py
index 421c853..4c65707 100644
--- a/client/vdsClientGluster.py
+++ b/client/vdsClientGluster.py
@@ -430,6 +430,70 @@
pp.pprint(status)
return status['status']['code'],
status['status']['message']
+ def do_glusterVolumeGeoRepConfigList(self, args):
+ params = self._eqSplit(args)
+ masterVolName = params.get('volumeName', '')
+ slaveHost = params.get('slaveHost', '')
+ slaveVolName = params.get('slaveVolName', '')
+ if not(masterVolName and slaveHost and slaveVolName):
+ raise ValueError
+
+ status = self.s.glusterVolumeGeoRepConfigList(masterVolName,
+ slaveHost,
+ slaveVolName)
+ pp.pprint(status)
+ return status['status']['code'],
status['status']['message']
+
+ def do_glusterVolumeGeoRepConfigSet(self, args):
+ params = self._eqSplit(args)
+ masterVolName = params.get('volumeName', '')
+ slaveHost = params.get('slaveHost', '')
+ slaveVolName = params.get('slaveVolName', '')
+ key = params.get('key', '')
+ value = params.get('value', '')
+ if not(masterVolName and slaveHost and slaveVolName and key and value):
+ raise ValueError
+
+ status = self.s.glusterVolumeGeoRepConfigSet(masterVolName,
+ slaveHost,
+ slaveVolName,
+ key,
+ value)
+ pp.pprint(status)
+ return status['status']['code'],
status['status']['message']
+
+ def do_glusterVolumeGeoRepConfigGet(self, args):
+ params = self._eqSplit(args)
+ masterVolName = params.get('volumeName', '')
+ slaveHost = params.get('slaveHost', '')
+ slaveVolName = params.get('slaveVolName', '')
+ key = params.get('key', '')
+ if not(masterVolName and slaveHost and slaveVolName and key):
+ raise ValueError
+
+ status = self.s.glusterVolumeGeoRepConfigGet(masterVolName,
+ slaveHost,
+ slaveVolName,
+ key)
+ pp.pprint(status)
+ return status['status']['code'],
status['status']['message']
+
+ def do_glusterVolumeGeoRepConfigSetDefault(self, args):
+ params = self._eqSplit(args)
+ masterVolName = params.get('volumeName', '')
+ slaveHost = params.get('slaveHost', '')
+ slaveVolName = params.get('slaveVolName', '')
+ key = params.get('key', '')
+ if not(masterVolName and slaveHost and slaveVolName and key):
+ raise ValueError
+
+ status = self.s.glusterVolumeGeoRepConfigSetDefault(masterVolName,
+ slaveHost,
+ slaveVolName,
+ key)
+ pp.pprint(status)
+ return status['status']['code'],
status['status']['message']
+
def getGlusterCmdDict(serv):
return \
@@ -731,4 +795,55 @@
('volumeName=<volume name>',
'Returns total, free and used space(bytes) of gluster volume'
)),
+ 'glusterVolumeGeoRepConfigList': (
+ serv.do_glusterVolumeGeoRepConfigList,
+ ('volumeName=<master_volume_name> slaveHost=<slave_host>
'
+ 'slaveVolName=<slave_volume_name>\n\t'
+ '<master_volume_name> is an existing volume name in '
+ 'the master node\n\t'
+ '<slave_host> is slave host name\n\t'
+ '<slave_volume_name> is an existing volume name '
+ 'in the slave node',
+ 'list volume geo-replication configurations'
+ )),
+ 'glusterVolumeGeoRepConfigSet': (
+ serv.do_glusterVolumeGeoRepConfigSet,
+ ('volumeName=<master_volume_name> slaveHost=<slave_host>
'
+ 'slaveVolName=<slave_volume_name> keyName=<key> '
+ 'value=<value>\n\t'
+ '<master_volume_name> is an existing volume name '
+ 'in the master node\n\t'
+ '<slave_host> is slave host name\n\t'
+ '<slave_volume_name> is an existing volume name in '
+ 'the slave node\n\t'
+ '<key> is the key name of configuration\n\t'
+ '<value> is the key value',
+ 'set volume geo-replication configuration'
+ )),
+ 'glusterVolumeGeoRepConfigGet': (
+ serv.do_glusterVolumeGeoRepConfigGet,
+ ('volumeName=<master_volume_name> slaveHost=<slave_host>
'
+ 'slaveVolName=<slave_volume_name> keyName=<key> '
+ 'value=<value>\n\t'
+ '<master_volume_name> is an existing volume name in '
+ 'the master node\n\t'
+ '<slave_host> is slave host name\n\t'
+ '<slave_volume_name> is an existing volume name in '
+ 'the slave node\n\t'
+ '<key> is the key name of configuration',
+ 'get volume geo-replication configuration'
+ )),
+ 'glusterVolumeGeoRepConfigSetDefault': (
+ serv.do_glusterVolumeGeoRepConfigSetDefault,
+ ('masterVolName=<master_volume_name> slaveHost=<slave_host>
'
+ 'slaveVolName=<slave_volume_name> keyName=<key> '
+ 'value=<value>\n\t'
+ '<master_volume_name> is an existing volume name in '
+ 'the master node\n\t'
+ '<slave_host> is slave host name\n\t'
+ '<slave_volume_name> is an existing volume name in '
+ 'the slave node\n\t'
+ '<key> is the key name',
+ 'Set volume geo-replication configuration to devault'
+ ))
}
diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py
index 0e6c850..5b3eec7 100644
--- a/vdsm/gluster/api.py
+++ b/vdsm/gluster/api.py
@@ -322,6 +322,46 @@
data = self.svdsmProxy.glusterVolumeStatvfs(volumeName)
return self._computeVolumeStats(data)
+ @exportAsVerb
+ def volumeGeoRepConfigList(self, masterVolName, slaveHost, slaveVolName,
+ options=None):
+ status = self.svdsmProxy.glusterVolumeGeoRepConfigList(masterVolName,
+ slaveHost,
+ slaveVolName)
+ return {'geoRepConfig': status}
+
+ @exportAsVerb
+ def volumeGeoRepConfigSet(self, masterVolName, slaveHost, slaveVolName,
+ key, value, options=None):
+ status = self.svdsmProxy.glusterVolumeGeoRepConfigSet(masterVolName,
+ slaveHost,
+ slaveVolName,
+ key,
+ value)
+ return {'geoRepSet': status}
+
+ @exportAsVerb
+ def volumeGeoRepConfigGet(self, masterVolName, slaveHost, slaveVolName,
+ key, options=None):
+
+ status = self.svdsmProxy.glusterVolumeGeoRepConfigGet(masterVolName,
+ slaveHost,
+ slaveVolName,
+ key)
+ return {'geoRepGet': status}
+
+ @exportAsVerb
+ def volumeGeoRepConfigSetDefault(self, masterVolName, slaveHost,
+ slaveVolName,
+ key, options=None):
+
+ status = self.svdsmProxy.glusterVolumeGeoRepConfigSetDefault(
+ masterVolName,
+ slaveHost,
+ slaveVolName,
+ key)
+ return {'geoRepSetDefault': status}
+
def getGlusterMethods(gluster):
l = []
diff --git a/vdsm/gluster/cli.py b/vdsm/gluster/cli.py
index 2e1c9a9..6a4ffd6 100644
--- a/vdsm/gluster/cli.py
+++ b/vdsm/gluster/cli.py
@@ -1054,3 +1054,74 @@
return _parseVolumeTasks(xmltree)
except _etreeExceptions:
raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+def _parseVolumeGeoRepConfigList(tree):
+ """
+ Returns:
+ {geoRepConfig:[{'option name': name of the configuration,
+ 'description': value of the configuration}]
+ }
+ """
+ result = {}
+ conf = tree.find('geoRep/config')
+ config_list = []
+ for child in conf.getchildren():
+ config = {}
+ config['optionName'] = child.tag
+ config['description'] = child.text
+ config_list.append(config)
+ result['geoRepConfig'] = config_list
+ return result
+
+
+@makePublic
+def volumeGeoRepConfigList(masterVolName, slaveHost, slaveVolName):
+ command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+ "%s::%s" % (slaveHost, slaveVolName),
+ "config"]
+ try:
+ xmltree = _execGlusterXml(command)
+ except ge.GlusterCmdFailedException as e:
+ raise ge.GlusterGeoRepConfigListFailedException(rc=e.rc, err=e.err)
+ try:
+ return _parseVolumeGeoRepConfigList(xmltree)
+ except _etreeExceptions:
+ raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+@makePublic
+def volumeGeoRepConfigSet(masterVolName, slaveHost, slaveVolName, key, value):
+ command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+ "%s::%s" % (slaveHost, slaveVolName),
+ "config", key, value]
+ rc, out, err = _execGluster(command)
+ if rc:
+ raise ge.GlusterGeoRepConfigSetFailedException(rc, out, err)
+ return True
+
+
+@makePublic
+def volumeGeoRepConfigGet(masterVolName, slaveHost, slaveVolName, key):
+ command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+ "%s::%s" % (slaveHost, slaveVolName),
+ "config", key]
+ try:
+ xmltree = _execGlusterXml(command)
+ except ge.GlusterCmdFailedException as e:
+ raise ge.GlusterGeoRepConfigGetFailedException(rc=e.rc, err=e.err)
+ try:
+ return _parseVolumeGeoRepConfigList(xmltree)
+ except _etreeExceptions:
+ raise ge.GlusterXmlErrorException(err=[etree.tostring(xmltree)])
+
+
+@makePublic
+def volumeGeoRepConfigSetDefault(masterVolName, slaveHost, slaveVolName, key):
+ command = _getGlusterVolCmd() + ["geo-replication", masterVolName,
+ "%s::%s" % (slaveHost, slaveVolName),
+ "config", "!%s" % key]
+ rc, out, err = _execGluster(command)
+ if rc:
+ raise ge.GlusterGeoRepConfigSetDefaultFailedException(rc, out, err)
+ return True
diff --git a/vdsm/gluster/exception.py b/vdsm/gluster/exception.py
index 0205cb1..ca6b7cf 100644
--- a/vdsm/gluster/exception.py
+++ b/vdsm/gluster/exception.py
@@ -506,3 +506,29 @@
class GlfsFiniException(GlusterLibgfapiException):
code = 4573
message = "glfs fini failed"
+
+
+#geo-replication
+class GlusterGeoRepException(GlusterException):
+ code = 4560
+ message = "Gluster Geo-Replication Exception"
+
+
+class GlusterGeoRepConfigListFailedException(GlusterVolumeException):
+ code = 4169
+ message = "Get volume geo-replication config list failed"
+
+
+class GlusterGeoRepConfigSetFailedException(GlusterVolumeException):
+ code = 4170
+ message = "Set volume geo-replication config failed"
+
+
+class GlusterGeoRepConfigGetFailedException(GlusterVolumeException):
+ code = 4171
+ message = "Get volume geo-replication config failed"
+
+
+class GlusterGeoRepConfigSetDefaultFailedException(GlusterVolumeException):
+ code = 4172
+ message = "Set volume geo-replication config to default failed"
diff --git a/vdsm/gluster/vdsmapi-gluster-schema.json
b/vdsm/gluster/vdsmapi-gluster-schema.json
index 4ddd182..06de6ca 100644
--- a/vdsm/gluster/vdsmapi-gluster-schema.json
+++ b/vdsm/gluster/vdsmapi-gluster-schema.json
@@ -1238,3 +1238,105 @@
{'command': {'class': 'GlusterVolume', 'name':
'statsInfoGet'},
'data': {'volumeName': 'str'},
'returns': 'GlusterVolumeStatsInfo'}
+
+# @GeoRepConfig:
+#
+# Geo replication config details.
+#
+# @optionname: Config option name
+#
+# @description: Option details
+#
+# Since: 4.16.0
+##
+{'type': 'GeoRepConfig',
+ 'data': {'optionname': 'str', 'description':
'str'}}
+
+##
+# @GlusterGeoRep.configList:
+#
+# List Geo Replication configuration
+#
+# @mastervolname: is an existing volume name in the master node
+#
+# @slavehost: is remote slave host name or ip
+#
+# @slavevolname: is an available existing volume name in the slave node
+#
+# Returns:
+# List of geo replication configurations
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterGeoRep', 'name':
'geoRepConfigList'},
+ 'data': {'mastervolname': 'str', 'slavehost':
'str', 'slavevolname': 'str'},
+ 'returns': 'GeoRepConfig'}
+
+##
+# @GlusterGeoRep.configSet:
+#
+# Set Geo Replication config option
+#
+# @mastervolname: is an existing volume name in the master node
+#
+# @slavehost: is remote slave host name or ip
+#
+# @slavevolname: is an available existing volume name in the slave node
+#
+# @key: valid configuration option name
+#
+# @value: value to the option
+#
+# Returns:
+# True if it sets value to the option successfully
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterGeoRep', 'name':
'geoRepConfigSet'},
+ 'data': {'mastervolname': 'str', 'slavehost':
'str', 'slavevolname': 'str', 'key': 'str',
'value': 'str'},
+ 'returns': 'bool'}
+
+##
+# @GlusterVolume.geoRepConfigGet:
+#
+# Get value of the Geo Replication config option
+#
+# @mastervolname: is an existing volume name in the master node
+#
+# @slavehost: is remote slave host name or ip
+#
+# @slavevolname: is an available existing volume name in the slave node
+#
+# @key: valid configuration option name
+#
+# Returns:
+# The value of the Geo Replication config option
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterGeoRep', 'name':
'geoRepConfigGet'},
+ 'data': {'mastervolname': 'str', 'slavehost':
'str', 'slavevolname': 'str', 'key': 'str'},
+ 'returns': 'GeoRepConfig'}
+
+##
+# @GlusterVolume.geoRepConfigSetDefault:
+#
+# Resets the the config option to default value
+#
+# @mastervolname: is an existing volume name in the master node
+#
+# @slavehost: is remote slave host name or ip
+#
+# @slavevolname: is an available existing volume name in the slave node
+#
+# @key: valid configuration option name
+#
+# Returns:
+# True if default value is set successfully
+#
+# Since: 4.16.0
+##
+{'command': {'class': 'GlusterGeoRep', 'name':
'geoRepConfigSetDefault'},
+ 'data': {'mastervolname': 'str', 'slavehost':
'str', 'slavevolname': 'str', 'key': 'str'},
+ 'returns': 'bool'}
+
--
To view, visit
http://gerrit.ovirt.org/30162
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifee571dbf3c56633e415d32f8d518cb64aaf1add
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Darshan N <dnarayan(a)redhat.com>