fix yamllint verify fail
[releng.git] / utils / test / testapi / update / templates / restore_mongodb.py
1 ##############################################################################
2 # Copyright (c) 2016 ZTE Corporation
3 # feng.xiaowei@zte.com.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import argparse
10
11 from utils import execute, main, get_abspath
12
13 parser = argparse.ArgumentParser(description='Restore MongoDBs')
14
15 parser.add_argument('-u', '--url',
16                     type=str,
17                     required=False,
18                     default='mongodb://127.0.0.1:27017/',
19                     help='Mongo DB URL for Backup')
20 parser.add_argument('-i', '--input_dir',
21                     type=str,
22                     required=True,
23                     help='Input directory for the Restore.')
24 parser.add_argument('-d', '--db',
25                     type=str,
26                     required=False,
27                     default='test_results_collection',
28                     help='database name after the restore.')
29
30
31 def restore(args):
32     input_dir = get_abspath(args.input_dir)
33     cmd = ['mongorestore', '%s' % input_dir]
34     execute(cmd, args)
35
36
37 if __name__ == '__main__':
38     main(restore, parser)