distaflibs.gluster.peer_ops module

Description: Library for gluster peer operations.

distaflibs.gluster.peer_ops.peer_probe(server, mnode=None)

Probe the specified server.

Parameters:server (str) – Server to be peer probed.
Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns: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.

Return type:tuple
distaflibs.gluster.peer_ops.peer_detach(server, force=False, mnode=None)

Detach the specified server.

Parameters:server (str) – Server to be peer detached.
Kwargs:
force (bool): option to detach peer.
Defaults to False.
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns: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.

Return type:tuple
distaflibs.gluster.peer_ops.peer_status(mnode=None)

Runs ‘gluster peer status’ on specified node.

Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns: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.

Return type:tuple
distaflibs.gluster.peer_ops.pool_list(mnode=None)

Runs ‘gluster pool list’ command on the specified node.

Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns: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.

Return type:tuple
distaflibs.gluster.peer_ops.peer_probe_servers(servers=None, validate=True, time_delay=10, mnode=None)

Probe specified servers and validate whether probed servers are in cluster and connected state if validate is set to True.

Kwargs:
servers (list): List of servers to be peer probed.
If None, defaults to nodes.
validate (bool): True to validate if probed peer is in cluster and
connected state. False otherwise. Defaults to True.
time_delay (int): time delay before validating peer status.
Defaults to 10 seconds.
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns:True on success and False on failure.
Return type:bool
distaflibs.gluster.peer_ops.peer_detach_servers(servers=None, force=False, validate=True, time_delay=10, mnode=None)

Detach peers and validate status of peer if validate is set to True.

Kwargs:
servers (list): List of servers to be peer detached.
If None, defaults to nodes.
force (bool): option to detach peer.
Defaults to False.
validate (bool): True if status of the peer needs to be validated,
False otherwise. Defaults to True.
time_delay (int): time delay before executing validating peer.
status. Defaults to 10 seconds.
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns:True on success and False on failure.
Return type:bool
distaflibs.gluster.peer_ops.nodes_from_pool_list(mnode=None)

Return list of nodes from the ‘gluster pool list’.

Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns:None if command execution fails. list: List of nodes in pool on Success, Empty list on failure.
Return type:NoneType
distaflibs.gluster.peer_ops.get_peer_status(mnode=None)

Parse the output of command ‘gluster peer status’.

Kwargs:
mnode (str): Node on which command has to be executed.
if None, defaults to nodes[0].
Returns:None if command execution fails or parse errors. list: list of dicts on success.
Return type:NoneType

Examples

>>> get_peer_status(mnode = 'abc.lab.eng.xyz.com')
[{'uuid': '77dc299a-32f7-43d8-9977-7345a344c398',
'hostname': 'ijk.lab.eng.xyz.com',
'state': '3',
'hostnames' : ['ijk.lab.eng.xyz.com'],
'connected': '1',
'stateStr': 'Peer in Cluster'},

{‘uuid’: ‘b15b8337-9f8e-4ec3-8bdb-200d6a67ae12’, ‘hostname’: ‘def.lab.eng.xyz.com’, ‘state’: ‘3’, ‘hostnames’: [‘def.lab.eng.xyz.com’], ‘connected’: ‘1’, ‘stateStr’: ‘Peer in Cluster’} ]

distaflibs.gluster.peer_ops.get_pool_list(mnode=None)

Parse the output of ‘gluster pool list’ command.

Kwargs:
mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns:None if command execution fails, parse errors. list: list of dicts on success.
Return type:NoneType

Examples

>>> get_pool_list(mnode = 'abc.lab.eng.xyz.com')
[{'uuid': 'a2b88b10-eba2-4f97-add2-8dc37df08b27',
'hostname': 'abc.lab.eng.xyz.com',
'state': '3',
'connected': '1',
'stateStr': 'Peer in Cluster'},

{‘uuid’: ‘b15b8337-9f8e-4ec3-8bdb-200d6a67ae12’, ‘hostname’: ‘def.lab.eng.xyz.com’, ‘state’: ‘3’, ‘hostnames’: [‘def.lab.eng.xyz.com’], ‘connected’: ‘1’, ‘stateStr’: ‘Peer in Cluster’} ]

distaflibs.gluster.peer_ops.is_peer_connected(servers=None, mnode=None)

Checks whether specified peers are in cluster and ‘Connected’ state.

Kwargs:
servers (list): List of servers to be validated.
If None, defaults to nodes.
mnode (str): Node from which peer probe has to be executed.
If None, defaults to nodes[0].
Returns
bool : True on success (peer in cluster and connected), False on
failure.