aboutsummaryrefslogtreecommitdiffstats
path: root/qtip/cli
diff options
context:
space:
mode:
authorTaseer <taseer94@gmail.com>2017-06-29 05:24:25 +0500
committerTaseer <taseer94@gmail.com>2017-06-29 21:04:03 +0500
commit0a3a3045b97eee0583de82b532880b96807bd82a (patch)
treea1e910bed36d6cfd0cdec151beee5e5e57e7a126 /qtip/cli
parent76cb6b08ce04492bd02bec43487a82f99a0a2c5f (diff)
Integrate Report with CLI.
- Migrate fixtures to conftest to be used by multiple files Change-Id: I9a705b93189ac1f2e6fd2fc4e3f05aec7af379f1 Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
Diffstat (limited to 'qtip/cli')
-rw-r--r--qtip/cli/commands/cmd_report.py47
1 files changed, 41 insertions, 6 deletions
diff --git a/qtip/cli/commands/cmd_report.py b/qtip/cli/commands/cmd_report.py
index 4176fd90..1a58aa60 100644
--- a/qtip/cli/commands/cmd_report.py
+++ b/qtip/cli/commands/cmd_report.py
@@ -7,11 +7,42 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from asq.initiators import query
import click
+from prettytable import PrettyTable
from qtip.reporter.console import ConsoleReporter
+def extract_section(sections, section_name, node):
+ """ Extract information related to QPI """
+ qpi = query(sections).where(lambda child: child['name'] == node) \
+ .select_many(lambda child: child['sections']) \
+ .where(lambda child: child['name'] == section_name) \
+ .first()
+ return qpi
+
+
+def display_report(report, section_name, node):
+ table_workload = PrettyTable(['Workload', 'Description',
+ 'Result', 'Score'])
+ table_workload.align = 'l'
+
+ section_report = extract_section(report['nodes'], section_name, node)
+
+ for metric in section_report['metrics']:
+ for wl in metric['workloads']:
+ table_workload.add_row([wl['name'],
+ wl['description'],
+ wl['result'],
+ wl['score']])
+ return {
+ "ss": section_report['score'],
+ "desc": section_report['description'],
+ "table": table_workload
+ }
+
+
@click.group()
def cli():
""" View QTIP results"""
@@ -19,9 +50,13 @@ def cli():
@cli.command('show')
-@click.argument('metric')
-@click.option('-p', '--path', help='Path to result directory')
-def show(metric, path):
- reporter = ConsoleReporter({})
- report = reporter.render(metric, path)
- click.echo(report)
+@click.option('-n', '--node', help="Compute node in OPNFV cluster")
+@click.argument('section-name')
+def show(node, section_name):
+ qpi = ConsoleReporter.load_result()
+ result = display_report(qpi, section_name, node)
+
+ click.echo("Node Score: {}".format(qpi['score']))
+ click.echo("Section Score: {}".format(result['ss']))
+ click.echo("Description: {}".format(result['desc']))
+ click.echo(result['table'])