distaflibs.gluster.snap_ops module¶
Description: Library for gluster snapshot operations.
-
distaflibs.gluster.snap_ops.snap_create(volname, snapname, timestamp=False, description='', force=False, mnode=None)¶ Creates snapshot for the given volume.
Example
snap_create(testvol, testsnap)
Parameters: - volname (str) – volume name
- snapname (str) – snapshot name
- Kwargs:
- timestamp (bool): If this option is set to True, then
- timestamps will get appended to the snapname. If this option is set to False, then timestamps will not be appended to snapname.
description (str): description for snapshot creation force (bool): If this option is set to True, then snap
create will get execute with force option. If it is set to False, then snap create will get executed without force option- mnode (str): Node on which cmd 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.snap_ops.snap_clone(snapname, clonename, mnode=None)¶ Clones the given snapshot
Example
snap_clone(testsnap, clone1)
Parameters: - snapname (str) – snapshot name to be cloned
- clonename (str) – clone name
- Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.snap_restore(snapname, mnode=None)¶ Executes snap restore cli for the given snapshot
Example
snap_restore(testsnap)
Parameters: snapname (str) – snapshot name to be cloned - Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.snap_restore_complete(volname, snapname, mnode=None)¶ stops the volume restore the snapshot and starts the volume
Example
snap_restore_complete(testvol, testsnap)
Parameters: - volname (str) – volume name
- snapname (str) – snapshot name
- Kwargs:
- mnode (str): Node on which cmd has to be executed.
- If None, defaults to nodes[0].
Returns: True on success, False on failure Return type: bool
-
distaflibs.gluster.snap_ops.snap_status(snapname='', volname='', mnode=None)¶ Runs ‘gluster snapshot status’ on specific node
Example
snap_status()
- Kwargs:
- mnode (str): Node on which cmd has to be executed.
- If None, defaults to nodes[0].
snapname (str): snapshot name volname (str): volume name
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.snap_ops.get_snap_status(mnode=None)¶ Parse the output of ‘gluster snapshot status’ 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 dict on success. Each snap status will be in dict formatReturn type: NoneType Examples
>>> get_snap_status(mnode = 'abc.lab.eng.xyz.com') [{'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11: testvol_brick0', 'pid': '26747', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}, {'path': '10.70.47.16:/testvol_brick1', 'pid': '25497', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}], 'brickCount': '2'}, 'name': 'snap2', 'uuid': '56a39a92-c339-47cc-a8b2-9e54bb2a6324'}, {'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11:testvol_next_brick0', 'pid': '26719', 'lvUsage': '4.93', 'volumeGroup': 'RHS_vg1', 'lvSize': '9.95g'}], 'brickCount': '1'}, 'name': 'next_snap1', 'uuid': 'dcf0cd31-c0db-47ad-92ec-f72af2d7b385'}]
-
distaflibs.gluster.snap_ops.get_snap_status_by_snapname(snapname, mnode=None)¶ - Parse the output of ‘gluster snapshot status’ command
- for the given snapshot.
Parameters: snapname (str) – snapshot name - 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. dict: on success. Return type: NoneType Examples
>>> get_snap_status_by_snapname('snap1', mnode = 'abc.lab.eng.xyz.com') {'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11: testvol_brick0', 'pid': '26747', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}, {'path': '10.70.47.16:/testvol_brick1', 'pid': '25497', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}], 'brickCount': '2'}, 'name': 'snap2', 'uuid': '56a39a92-c339-47cc-a8b2-9e54bb2a6324'}
-
distaflibs.gluster.snap_ops.get_snap_status_by_volname(volname, mnode=None)¶ - Parse the output of ‘gluster snapshot status’ command
- for the given volume.
Parameters: volname (str) – snapshot name - 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_snap_status_by_volname('testvol', mnode = 'abc.lab.eng.xyz.com') [{'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11: testvol_brick0', 'pid': '26747', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}, {'path': '10.70.47.16:/testvol_brick1', 'pid': '25497', 'lvUsage': '3.52', 'volumeGroup': 'RHS_vg0', 'lvSize': '9.95g'}], 'brickCount': '2'}, 'name': 'snap2', 'uuid': '56a39a92-c339-47cc-a8b2-9e54bb2a6324'}, {'volCount': '1', 'volume': {'brick': [{'path': '10.70.47.11:testvol_next_brick0', 'pid': '26719', 'lvUsage': '4.93', 'volumeGroup': 'RHS_vg1', 'lvSize': '9.95g'}], 'brickCount': '1'}, 'name': 'next_snap1', 'uuid': 'dcf0cd31-c0db-47ad-92ec-f72af2d7b385'}]
-
distaflibs.gluster.snap_ops.snap_info(snapname='', volname='', mnode=None)¶ Runs ‘gluster snapshot info’ on specific node
Example
snap_info()
- Kwargs:
- mnode (str): Node on which cmd has to be executed.
- If None, defaults to nodes[0].
snapname (str): snapshot name volname (str): volume name
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.snap_ops.get_snap_info(mnode=None)¶ Parse the output of ‘gluster snapshot info’ 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_snap_info(mnode = 'abc.lab.eng.xyz.com') [{'description': 'This is snap2', 'uuid': '56a39a92-c339-47cc-a8b2-9e54bb2a6324', 'volCount': '1', 'snapVolume': {'status': 'Stopped', 'name': 'df1882d3f86d48738e69f298096f3810'}, 'createTime': '2016-04-07 12:01:21', 'name': 'snap2'}, {'description': None, 'uuid': 'a322d93a-2732-447d-ab88-b943fa402fd2', 'volCount': '1', 'snapVolume': {'status': 'Stopped', 'name': '2c790e6132e447e79168d9708d4abfe7'}, 'createTime': '2016-04-07 13:59:43', 'name': 'snap1'}]
-
distaflibs.gluster.snap_ops.get_snap_info_by_snapname(snapname, mnode=None)¶ - Parse the output of ‘gluster snapshot info’ command
- for the given snapshot.
Parameters: snapname (str) – snapshot name - 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. dict: on success. Return type: NoneType Examples
>>> get_snap_info_by_snapname('snap1', mnode = 'abc.lab.eng.xyz.com') {'description': 'This is snap2', 'uuid': '56a39a92-c339-47cc-a8b2-9e54bb2a6324', 'volCount': '1', 'snapVolume': {'status': 'Stopped', 'name': 'df1882d3f86d48738e69f298096f3810'}
-
distaflibs.gluster.snap_ops.get_snap_info_by_volname(volname, mnode=None)¶ - Parse the output of ‘gluster snapshot info’ command
- for the given volume.
Parameters: volname (str) – snapshot name - 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_snap_info_by_volname('testvol', mnode = 'abc.lab.eng.xyz.com') {'originVolume': {'snapCount': '1', 'name': 'testvol', 'snapRemaining': '255'}, 'count': '1', 'snapshots': [{'description': 'This is next snap1', 'uuid': 'dcf0cd31-c0db-47ad-92ec-f72af2d7b385', 'volCount': '1', 'snapVolume': {'status': 'Stopped', 'name': '49c290d6e8b74205adb3cce1206b5bc5'}, 'createTime': '2016-04-07 12:03:11', 'name': 'next_snap1'}]}
-
distaflibs.gluster.snap_ops.snap_list(mnode=None)¶ Lists the snapshots
Example
snap_list()
- Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.get_snap_list(mnode=None)¶ Parse the output of ‘gluster snapshot 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 snapshots on success. Return type: NoneType Examples
>>> get_snap_list(mnode = 'abc.lab.eng.xyz.com') ['snap1', 'snap2']
-
distaflibs.gluster.snap_ops.snap_config(volname=None, mnode=None)¶ Runs ‘gluster snapshot config’ on specific node
Example
snap_config()
- Kwargs:
volname (str): volume name mnode (str): Node on which cmd 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.snap_ops.get_snap_config(volname=None, mnode=None)¶ Parse the output of ‘gluster snapshot config’ command.
- Kwargs:
volname (str): volume name mnode (str): Node on which command has to be executed.
If None, defaults to nodes[0].
Returns: None if command execution fails, parse errors. dict: on success. Return type: NoneType Examples
>>> get_snap_config() {'volumeConfig': [{'softLimit': '230', 'effectiveHardLimit': '256', 'name': 'testvol', 'hardLimit': '256'}, {'softLimit': '230', 'effectiveHardLimit': '256', 'name': 'testvol_next', 'hardLimit': '256'}], 'systemConfig': {'softLimit': '90%', 'activateOnCreate': 'disable', 'hardLimit': '256', 'autoDelete': 'disable'}}
-
distaflibs.gluster.snap_ops.set_snap_config(option, volname=None, mnode=None)¶ Sets given snap config on the given node
Example
>>>option={‘snap-max-hard-limit’:‘200’} set_snap_config(option)
Parameters: option (dict) – dict of single snap config option - Kwargs:
volname (str): volume name mnode (str): Node on which cmd 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.snap_ops.snap_delete(snapname, mnode=None)¶ Deletes the given snapshot
Example
snap_delete(testsnap)
Parameters: snapname (str) – snapshot name to be deleted - Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.snap_delete_by_volumename(volname, mnode=None)¶ Deletes the given snapshot
Example
snap_delete_by_volumename(testvol)
Parameters: volname (str) – volume name - Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.snap_delete_all(mnode=None)¶ Deletes all the snapshot in the cluster
Example
snap_delete_all(testsnap)
- Kwargs:
- mnode (str): Node on which cmd 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.snap_ops.snap_activate(snapname, force=False, mnode=None)¶ Activates the given snapshot
Example
snap_activate(testsnap)
Parameters: snapname (str) – snapshot name to be cloned - Kwargs:
- force (bool): If this option is set to True, then snap
- activate will get execute with force option. If it is set to False, then snap activate will get executed without force option
- mnode (str): Node on which cmd 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.snap_ops.snap_deactivate(snapname, mnode=None)¶ Deactivates the given snapshot
Example
snap_deactivate(testsnap)
Parameters: snapname (str) – snapshot name to be cloned - Kwargs:
- mnode (str): Node on which cmd 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