summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/brickmux_ops.py
blob: 6f5480890c7bcb23cfb2e32c1d14c6afb7ba32e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
#  Copyright (C) 2017-2018  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
#  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 brick multiplex operations
"""

from glusto.core import Glusto as g


def is_brick_mux_enabled(mnode):
    """Checks for brick multiplex operation enabled or not

    Args:
        mnode (str): Node on which cmd has to be executed.

    Returns:
        bool : True if successfully enabled brickmux. False otherwise.
    """
    cmd = ("gluster v get all all | grep cluster.brick-multiplex |"
           "awk '{print $2}'")
    ret, out, err = g.run(mnode, cmd)
    if "enable" in out:
        return True
    else:
        return False


def enable_brick_mux(mnode):
    """Enables brick multiplex operation on all servers

    Args:
        mnode (str): Node on which cmd has to be executed.

    Returns:
        bool : True if successfully enabled brickmux. False otherwise.
    """
    cmd = ("gluster v set all cluster.brick-multiplex enable")
    _, out, _ = g.run(mnode, cmd)
    if "success" in out:
        return True
    return False