-
Notifications
You must be signed in to change notification settings - Fork 24
/
clusterbuster-report
executable file
·46 lines (39 loc) · 1.82 KB
/
clusterbuster-report
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
#!/usr/bin/env python3
# Copyright 2022 Robert Krawitz/Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import argparse
from lib.clusterbuster.reporting.reporter.ClusterBusterReporter import ClusterBusterReporter
import traceback
import os
if 'CB_LIBPATH' in os.environ:
sys.path = [element for element in os.environ['CB_LIBPATH'].split(':')] + sys.path
parser = argparse.ArgumentParser(description='Generate ClusterBuster report')
report_formats = ClusterBusterReporter.list_report_formats()
parser.add_argument('-o', '--format', '--output_format', '--output', '--report-format',
default='summary', metavar='format', type=str,
choices=report_formats, help=f'Report format: one of {", ".join(report_formats)}')
parser.add_argument('--list_formats', action='store_true', help='List available report formats')
parser.add_argument("files", metavar='file', type=str, nargs='*', help='Files to process')
args, extras = parser.parse_known_args()
if args.list_formats:
print('\n'.join(sorted(report_formats)))
sys.exit(1)
try:
ClusterBusterReporter.print_report(args.files, report_format=args.format, extras=extras)
except (KeyboardInterrupt, BrokenPipeError):
sys.exit(1)
except Exception:
print(f"Decoding JSON failed: {traceback.format_exc()}", file=sys.stderr)
sys.exit(1)