summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-02-17 13:15:28 +0530
committerBala Konda Reddy M <bala12352@gmail.com>2020-03-02 16:17:16 +0000
commit8616ac1e44316ead3fea05e5b2c51d7a97b8eb4a (patch)
tree71ab963b3c742fff5eaa156c0e08706a6c0aace7 /glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py
parent7c860f945906b824da49755d7bc883b4d6c4e5ee (diff)
[lib] Add functionality to setup master and slave volumes
Adding the code for the following: 1.Adding function setup_master_and_slave_volumes() to geo_rep_libs. 2.Adding variables for master_mounts, slave_mounts, master_volume and slave_volume to gluster_base_class.py 3.Adding class class method setup_and_mount_geo_rep_master_and_slave_volumes to gluster_base_class.py. Change-Id: Ic8ae1cb1c8b5719d4774996c3e9e978551414b44 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py59
1 files changed, 58 insertions, 1 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py b/glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py
index a850681ce..20531b946 100644
--- a/glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/geo_rep_libs.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2018 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (C) 2017-2020 Red Hat, Inc. <http://www.redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@ from glustolibs.gluster.lib_utils import (group_add, ssh_copy_id,
is_group_exists, is_user_exists,
is_passwordless_ssh_configured)
from glustolibs.gluster.glusterdir import get_dir_contents
+from glustolibs.gluster.volume_ops import set_volume_options
+from glustolibs.gluster.volume_libs import setup_volume
def georep_prerequisites(mnode, snode, passwd, user="root", group=None,
@@ -302,3 +304,58 @@ def georep_create_session(mnode, snode, mastervol, slavevol,
(user, mastervol, slavevol))
return False
return True
+
+
+def setup_master_and_slave_volumes(mnode, all_servers_info,
+ master_volume_config,
+ snode, all_slaves_info,
+ slave_volume_config,
+ force=False):
+ """Create master and slave volumes for geo-replication.
+
+ Args:
+ mnode(str): The primary master node where the commands are executed.
+ all_servers_info(dict): Information about all master servers.
+ master_volume_config(dict): Dict containing volume information
+ of master.
+ snode(str): slave node where the commande are executed.
+ all_slaves_info(dict): Information about all slave servers.
+ slave_volume_config(dict): Dict containing volume information
+ of slave.
+ kwargs:
+ force(bool): If set to true then will create volumes
+ with force option.
+
+ Returns:
+ bool : True if volumes created successfully, false if there are
+ any failures in the middle.
+
+ Example:
+ setup_master_and_slave_volumes(
+ cls.mode, cls.all_servers_info, cls.master_volume,
+ cls.snode, cls.all_slaves_info, cls.slave_volume)
+ >>> True
+ """
+ # Setting up the master and the slave volume.
+ ret = setup_volume(mnode, all_servers_info, master_volume_config,
+ force)
+ if not ret:
+ g.log.error("Failed to Setup master volume %s",
+ master_volume_config['name'])
+ return False
+
+ ret = setup_volume(snode, all_slaves_info, slave_volume_config,
+ force)
+ if not ret:
+ g.log.error("Failed to Setup slave volume %s",
+ slave_volume_config['name'])
+ return False
+
+ # Setting performance.quick-read to off.
+ ret = set_volume_options(snode, slave_volume_config['name'],
+ {"performance.quick-read": "off"})
+ if not ret:
+ g.log.error("Failed to performance.quick-read to off on "
+ "slave volume %s", slave_volume_config['name'])
+ return False
+ return True