-
Notifications
You must be signed in to change notification settings - Fork 2
/
rbd_brctl.py
executable file
·47 lines (37 loc) · 1.17 KB
/
rbd_brctl.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Yu-Jung Cheng
#
# a warper program (manager) to integrate with all RBD backup restore functions.
#
import os, sys
def main(argument_list):
# value will replaced by install.sh
python_path = '_PYTHON_PATH_'
install_path = '_INSTALL_PATH_'
try:
if len(argument_list) == 1:
print("Please pass arguments as instruction to the RBD backup restore tool.")
return
cmd_sub = argument_list[1]
cmd_opt = ' '.join(argument_list[2:])
if cmd_sub == 'show':
cmd = "./backup_show.py"
elif cmd_sub == 'delete':
cmd = "./backup_delete.py"
elif cmd_sub == 'backup':
cmd = "./rbd_backup.py"
elif cmd_sub == 'restore':
cmd = "./rbd_restore.py"
else:
print("Unrecognized instruction '%s'." % cmd_sub)
sys.exit(2)
cmd = "%s %s %s" % (python_path, cmd, cmd_opt)
os.chdir(install_path)
os.system(cmd)
except Exception as e:
print("Error, %s" % e)
return 2
if "__main__" == __name__:
return_code = main(sys.argv)
sys.exit(return_code)