From 144e2a1bfe80211fe02775da2386f57122001710 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Mon, 18 Jun 2018 04:48:37 -0400 Subject: Geo-rep: Config get and set options Change-Id: I6cb2a321cd774e5c1008d27c42d9df9219e74ff0 Signed-off-by: rallan Signed-off-by: Kotresh HR --- .../glustolibs/gluster/geo_rep_ops.py | 71 +++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) (limited to 'glustolibs-gluster/glustolibs') diff --git a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py index 5e9a09b77..88ad8ae80 100644 --- a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py @@ -125,18 +125,75 @@ def georep_create(mnode, mastervol, slaveip, slavevol, user=None, force=False): """ if user: if force: - cmd = "gluster volume geo-replication %s %s@%s::%s create push-pem \ - force" % (mastervol, user, slaveip, slavevol) + cmd = "gluster volume geo-replication %s %s@%s::%s create \ + push-pem force" % (mastervol, user, slaveip, slavevol) else: cmd = "gluster volume geo-replication %s %s@%s::%s create \ - push-pem" % (mastervol, user, slaveip, slavevol) + create push-pem" % (mastervol, user, slaveip, slavevol) else: if force: - cmd = "gluster volume geo-replication %s %s::%s create push-pem \ - force" % (mastervol, slaveip, slavevol) - else: cmd = "gluster volume geo-replication %s %s::%s create \ - push-pem" % (mastervol, slaveip, slavevol) + push-pem force" % (mastervol, slaveip, slavevol) + else: + cmd = "gluster volume geo-replication %s %s::%s \ + create push-pem" % (mastervol, slaveip, slavevol) + return g.run(mnode, cmd) + + +def georep_config_get(mnode, mastervol, slaveip, slavevol, config_key): + """ All the available configurable geo-rep options can be got + using the config_key and seeing what it has been set to + + Args: + mnode (str) : Node on which cmd is to be executed + mastervol (str) : The name of the mastervol + slaveip (str): SlaveIP + slavevol (str) The name of the slave volume + config_key (str): The configurable options available in geo-replication + Returns: + tuple: Tuple containing three elements (ret, out, err). + The first element 'ret' is of type 'int' and is the return value + of command execution. + + The second element 'out' is of type 'str' and is the stdout value + of the command execution. In this case, it contains value of + config. + + The third element 'err' is of type 'str' and is the stderr value + of the command execution. + + """ + cmd = ("gluster volume geo-replication %s %s::%s config %s" % + (mastervol, slaveip, slavevol, config_key)) + return g.run(mnode, cmd) + + +def georep_config_set(mnode, mastervol, slaveip, slavevol, config, value): + """ All the available configurable geo-rep options can be set with a + specific command if required or + just with the config parameter + Args: + mnode (str) : Node on which cmd is to be executed + mastervol (str) : The name of the mastervol + slaveip (str): SlaveIP + slavevol (str) The name of the slave volume + config (str): The configurable options available in geo-replication + Kwargs: + value (str): The value for the geo-rep config + Returns: + tuple: Tuple containing three elements (ret, out, err). + The first element 'ret' is of type 'int' and is the return value + of command execution. + + The second element 'out' is of type 'str' and is the stdout value + of the command execution. + + The third element 'err' is of type 'str' and is the stderr value + of the command execution. + + """ + cmd = ("gluster volume geo-replication %s %s::%s config %s %s" % + (mastervol, slaveip, slavevol, config, value)) return g.run(mnode, cmd) -- cgit