]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/usr/bin/env python |
2 | # | |
3 | # Copyright (C) 2015 <contact@redhat.com> | |
4 | # Copyright (C) 2015 SUSE LINUX GmbH | |
5 | # | |
6 | # Author: Alfredo Deza <alfredo.deza@inktank.com> | |
7 | # Author: Owen Synge <osynge@suse.com> | |
8 | # Author: Loic Dachary <loic@dachary.org> | |
9 | # | |
10 | # This program is free software; you can redistribute it and/or modify | |
11 | # it under the terms of the GNU Library Public License as published by | |
12 | # the Free Software Foundation; either version 2, or (at your option) | |
13 | # any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, | |
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | # GNU Library Public License for more details. | |
19 | # | |
20 | import argparse | |
21 | import logging | |
22 | ||
23 | import ceph_detect_init | |
24 | from ceph_detect_init import exc | |
25 | ||
26 | ||
27 | def parser(): | |
28 | parser = argparse.ArgumentParser( | |
29 | 'ceph-detect-init', | |
30 | ) | |
31 | parser.add_argument( | |
32 | "-v", | |
33 | "--verbose", | |
34 | action="store_true", | |
35 | default=None, | |
36 | ) | |
37 | parser.add_argument( | |
38 | "--use-rhceph", | |
39 | action="store_true", | |
40 | default=False, | |
41 | ) | |
42 | parser.add_argument( | |
43 | "--default", | |
44 | default=None, | |
45 | ) | |
46 | return parser | |
47 | ||
48 | ||
49 | def run(argv=None, namespace=None): | |
50 | args = parser().parse_args(argv, namespace) | |
51 | ||
52 | if args.verbose: | |
53 | logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', | |
54 | level=logging.DEBUG) | |
55 | try: | |
56 | print(ceph_detect_init.get(args.use_rhceph).init) | |
57 | except exc.UnsupportedPlatform: | |
58 | if args.default: | |
59 | print(args.default) | |
60 | else: | |
61 | raise | |
62 | ||
63 | return 0 |