Option to enable/disble automatic timeline snapshots

Signed-off-by: Hanisha P<hanishap@thoughtworks.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
hanisha authored and Joseph Nuthalapati committed 2017-12-18 12:21:01 +05:30
1 parent a2997a0c70
commit 76ffad7955
5 files changed
+126 -25

No files matched your search

+21
View File
@@ -38,6 +38,7 @@ def parse_arguments():
subparsers.add_parser('setup', help='Configure snapper')
subparsers.add_parser('list', help='List snapshots')
subparsers.add_parser('create', help='Create snapshot')
subparsers.add_parser('get-config', help='Configurations of snapshot')
subparser = subparsers.add_parser('delete',
help='Delete a snapshot by number')
@@ -46,6 +47,10 @@ def parse_arguments():
subparser = subparsers.add_parser('delete-all',
help='Delete all the snapshots')
subparser = subparsers.add_parser('configure',
help='Configure automatic snapshots')
subparser.add_argument('config')
subparser = subparsers.add_parser('rollback', help='Rollback to snapshot')
subparser.add_argument('number', help='Number of snapshot to rollback to')
@@ -163,6 +168,22 @@ def subcommand_delete_all(_):
subprocess.run(command, check=True)
def subcommand_configure(arguments):
command = ['snapper', 'set-config', arguments.config]
subprocess.run(command, check=True)
def subcommand_get_config(_):
command = ['snapper', 'get-config']
process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
lines = process.stdout.decode().splitlines()
config = {}
for line in lines[2:]:
parts = [part.strip() for part in line.split('|')]
config[parts[0]] = parts[1]
print(json.dumps(config))
def subcommand_rollback(arguments):
"""Rollback to snapshot."""
command = [