| from cfg_checker.common import logger_cli |
| from cfg_checker.common.settings import ENV_TYPE_KUBE |
| from cfg_checker.helpers import args_utils |
| from cfg_checker.modules.ceph import info, bench |
| |
| command_help = "Ceph Storage information and benchmarks" |
| supported_envs = [ENV_TYPE_KUBE] |
| |
| |
| # def _selectClass(_env, strClassHint="checker"): |
| # _class = None |
| # if _env == ENV_TYPE_SALT: |
| # if strClassHint == "info": |
| # _class = info.SaltCephInfo |
| # elif strClassHint == "bench": |
| # _class = bench.SaltCephInfo |
| # elif _env == ENV_TYPE_KUBE: |
| # if strClassHint == "info": |
| # _class = info.KubeCephInfo |
| # elif strClassHint == "bench": |
| # _class = bench.KubeCephBench |
| # if not _class: |
| # raise CheckerException( |
| # "Unknown hint for selecting Ceph handler Class: '{}'".format( |
| # strClassHint |
| # ) |
| # ) |
| # else: |
| # return _class |
| |
| |
| def init_parser(_parser): |
| # network subparser |
| ceph_subparsers = _parser.add_subparsers(dest='type') |
| |
| ceph_info_parser = ceph_subparsers.add_parser( |
| 'info', |
| help="Gather Ceph Cluster information" |
| ) |
| |
| ceph_info_parser.add_argument( |
| '--detailed', |
| action="store_true", default=False, |
| help="Print additional details" |
| ) |
| |
| ceph_info_parser.add_argument( |
| '--tgz', |
| metavar='ceph_tgz_filename', |
| help="HTML filename to save report" |
| ) |
| |
| ceph_report_parser = ceph_subparsers.add_parser( |
| 'report', |
| help="Generate network check report" |
| ) |
| |
| ceph_report_parser.add_argument( |
| '--html', |
| metavar='ceph_html_filename', |
| help="HTML filename to save report" |
| ) |
| |
| ceph_bench_parser = ceph_subparsers.add_parser( |
| 'bench', |
| help="Run ceph benchmark" |
| ) |
| |
| ceph_bench_parser.add_argument( |
| '--task-list', |
| metavar='ceph_tasks_filename', |
| help="List file with data for Ceph bench testrun" |
| ) |
| |
| return _parser |
| |
| |
| def do_info(args, config): |
| # Ceph info |
| # Gather ceph info and create an archive with data |
| args_utils.check_supported_env(ENV_TYPE_KUBE, args, config) |
| # check tgz |
| _tgzfile = "ceph_info_archive.tgz" if not args.tgz else args.tgz |
| |
| # _class = _selectClass(_env) |
| ceph_info = info.KubeCephInfo(config) |
| |
| logger_cli.info("# Collecting Ceph cluster information") |
| ceph_info.gather_info() |
| |
| # Debug, enable if needed to debug report generation |
| # without actuall data collecting each time |
| # ceph_info.dump_info() |
| # ceph_info.load_info() |
| # end debug |
| |
| ceph_info.generate_archive(_tgzfile) |
| ceph_info.print_summary() |
| |
| return |
| |
| |
| def do_report(args, config): |
| # Ceph Report |
| # Gather ceph info and create HTML report with all of the data |
| args_utils.check_supported_env(ENV_TYPE_KUBE, args, config) |
| _filename = args_utils.get_arg(args, 'html') |
| logger_cli.info("# Ceph cluster Configuration report") |
| |
| # _class = _selectClass(_env) |
| ceph_info = info.KubeCephInfo(config) |
| # Debug, enable if needed to debug report generation |
| # without actuall data collecting each time |
| # ceph_info.load_info() |
| # end debug |
| ceph_info.gather_info() |
| ceph_info.get_transposed_latency_table() |
| ceph_info.get_latest_health_readout() |
| ceph_info.create_html_report(_filename) |
| |
| return |
| |
| |
| def do_bench(args, config): |
| # Ceph Benchmark using multiple pods |
| # Prepare the tasks and do synced testrun |
| # TODO: html option to create a fancy report |
| args_utils.check_supported_env(ENV_TYPE_KUBE, args, config) |
| |
| ceph_bench = bench.KubeCephBench(config) |
| |
| logger_cli.error("ERROR: To be implemented...") |
| |
| # Load tasks |
| |
| # Do the testrun |
| ceph_bench.prepare_pods() |
| ceph_bench.run_benchmark() |
| |
| # Create report |
| ceph_bench.create_report() |
| |
| return |