cfg-checker bench part 1

 - first single test debug portion
 - updated fio option extraction
 - updated date interaction
 - fixed agent error showing and handling

 Related-PROD: PROD-36669

Change-Id: I7c1014c01b5b84429f112bff8db5ad34944c4644
diff --git a/cfg_checker/modules/ceph/__init__.py b/cfg_checker/modules/ceph/__init__.py
index 495e9b1..9d0f923 100644
--- a/cfg_checker/modules/ceph/__init__.py
+++ b/cfg_checker/modules/ceph/__init__.py
@@ -1,3 +1,4 @@
+from cfg_checker.agent.fio_runner import get_fio_options
 from cfg_checker.common import logger_cli
 from cfg_checker.common.settings import ENV_TYPE_KUBE
 from cfg_checker.helpers import args_utils
@@ -71,6 +72,26 @@
         metavar='ceph_tasks_filename',
         help="List file with data for Ceph bench testrun"
     )
+    ceph_bench_parser.add_argument(
+        '--agents',
+        type=int, metavar='agent_count', default=5,
+        help="List file with data for Ceph bench testrun"
+    )
+    ceph_bench_parser.add_argument(
+        '--html',
+        metavar='ceph_html_filename',
+        help="HTML filename to save report"
+    )
+    ceph_bench_parser.add_argument(
+        '--storage-class',
+        metavar='storage_class',
+        help="Storage class to be used in benchmark"
+    )
+    ceph_bench_parser.add_argument(
+        '--task-file',
+        metavar='task-file',
+        help="Task file for benchmark"
+    )
 
     return _parser
 
@@ -123,21 +144,45 @@
 
 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
+    # Prepare the tasks and do synced testrun or a single one
+    logger_cli.info("# Initializing benchmark run")
     args_utils.check_supported_env(ENV_TYPE_KUBE, args, config)
+    _filename = args_utils.get_arg(args, 'html')
+    # agents count option
+    _agents = args_utils.get_arg(args, "agents")
+    logger_cli.info("-> using {} agents".format(_agents))
+    config.bench_agent_count = _agents
+    # storage class
+    _storage_class = args_utils.get_arg(args, "storage_class")
+    logger_cli.info("-> using storage class of '{}'".format(_storage_class))
+    config.bench_storage_class = _storage_class
+    # Task files or options
+    _task_file = args_utils.get_arg(args, "task_file", nofail=True)
+    if not _task_file:
+        logger_cli.info("-> running single run")
+        config.bench_mode = "single"
+    else:
+        logger_cli.info("-> running with tasks from '{}'".format(_task_file))
+        config.bench_task_file = _task_file
+        config.bench_mode = "tasks"
+    _opts = get_fio_options()
+    logger_cli.debug("... default/selected options for fio:")
+    for _k in _opts.keys():
+        # TODO: Update options for single run
+        logger_cli.debug("    {} = {}".format(_k, _opts[_k]))
 
+    # handle option inavailability
     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()
+    ceph_bench.prepare_agents(_opts)
+    if not ceph_bench.run_benchmark(_opts):
+        return
+    ceph_bench.cleanup()
 
     # Create report
-    ceph_bench.create_report()
+    ceph_bench.create_report(_filename)
 
     return