From b8e32480bd75fc6dfc2cd1eb7eaac67e13f420ee Mon Sep 17 00:00:00 2001 From: Shwetha Panduranga Date: Mon, 3 Oct 2016 14:59:03 +0530 Subject: Adding libs for brick ops, volume helpers, mount helpers, gluster base class, heal related helpers, samba helpers, and windows ops helpers Change-Id: I0ad8fc7548c88e89d2ba6441166b9a38af76cea0 Signed-off-by: Shwetha Panduranga --- glustolibs-gluster/glustolibs/gluster/uss_ops.py | 114 +++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 glustolibs-gluster/glustolibs/gluster/uss_ops.py (limited to 'glustolibs-gluster/glustolibs/gluster/uss_ops.py') diff --git a/glustolibs-gluster/glustolibs/gluster/uss_ops.py b/glustolibs-gluster/glustolibs/gluster/uss_ops.py new file mode 100644 index 000000000..3275a6e61 --- /dev/null +++ b/glustolibs-gluster/glustolibs/gluster/uss_ops.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# Copyright (C) 2015-2016 Red Hat, Inc. +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +""" + Description: Module for gluster uss operations +""" + +from glusto.core import Glusto as g + + +def enable_uss(mnode, volname): + """Enables uss on the specified volume + + Args: + mnode (str): Node on which cmd has to be executed. + volname (str): volume name + + 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 set %s features.uss enable" % volname + return g.run(mnode, cmd) + +def disable_uss(mnode, volname): + """Disables uss on the specified volume + + Args: + mnode (str): Node on which cmd has to be executed. + volname (str): volume name + + 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 set %s features.uss disable" % volname + return g.run(mnode, cmd) + + +def is_uss_enabled(mnode, volname): + """Check if uss is Enabled on the specified volume + + Args: + mnode (str): Node on which cmd has to be executed. + volname (str): volume name + + Returns: + bool : True if successfully enabled uss on the volume. False otherwise. + """ + from glustolibs.gluster.volume_ops import get_volume_options + option_dict = get_volume_options(mnode=mnode, volname=volname, + option="uss") + if option_dict is None: + g.log.error("USS is not set on the volume %s" % volname) + return False + + if ('features.uss' in option_dict and + option_dict['features.uss'] == 'enable'): + return True + else: + return False + + +def is_uss_disabled(mnode, volname): + """Check if uss is disabled on the specified volume + + Args: + mnode (str): Node on which cmd has to be executed. + volname (str): volume name + + Returns: + bool : True if successfully disabled uss on the volume. + False otherwise. + """ + from glustolibs.gluster.volume_ops import get_volume_options + option_dict = get_volume_options(mnode=mnode, volname=volname, + option="uss") + if option_dict is None: + g.log.error("USS is not set on the volume %s" % volname) + return False + + if ('features.uss' in option_dict and + option_dict['features.uss'] == 'disable'): + return True + else: + return False -- cgit