summaryrefslogtreecommitdiffstats
path: root/qtip
diff options
context:
space:
mode:
Diffstat (limited to 'qtip')
-rw-r--r--qtip/ansible_library/plugins/action/aggregate.py12
-rw-r--r--qtip/ansible_library/plugins/action/calculate.py30
-rw-r--r--qtip/cli/commands/cmd_plan.py69
-rw-r--r--qtip/cli/commands/cmd_project.py34
-rw-r--r--qtip/cli/utils.py2
5 files changed, 53 insertions, 94 deletions
diff --git a/qtip/ansible_library/plugins/action/aggregate.py b/qtip/ansible_library/plugins/action/aggregate.py
index f1451e06..36ea0ef1 100644
--- a/qtip/ansible_library/plugins/action/aggregate.py
+++ b/qtip/ansible_library/plugins/action/aggregate.py
@@ -42,9 +42,15 @@ class ActionModule(ActionBase):
# aggregate QPI results
@export_to_file
def aggregate(hosts, basepath, src):
- host_results = [{'host': host, 'result': json.load(open(os.path.join(basepath, host, src)))} for host in hosts]
- score = int(mean([r['result']['score'] for r in host_results]))
+ host_results = []
+ for host in hosts:
+ host_result = json.load(open(os.path.join(basepath, host, src)))
+ host_result['name'] = host
+ host_results.append(host_result)
+ score = int(mean([r['score'] for r in host_results]))
return {
'score': score,
- 'host_results': host_results
+ 'name': 'compute',
+ 'description': 'POD Compute QPI',
+ 'children': host_results
}
diff --git a/qtip/ansible_library/plugins/action/calculate.py b/qtip/ansible_library/plugins/action/calculate.py
index 8d5fa1f7..077d863c 100644
--- a/qtip/ansible_library/plugins/action/calculate.py
+++ b/qtip/ansible_library/plugins/action/calculate.py
@@ -55,18 +55,22 @@ def calc_qpi(qpi_spec, metrics):
display.vvv("spec: {}".format(qpi_spec))
display.vvv("metrics: {}".format(metrics))
- section_results = [{'name': s['name'], 'result': calc_section(s, metrics)}
+ section_results = [calc_section(s, metrics)
for s in qpi_spec['sections']]
# TODO(yujunz): use formula in spec
standard_score = 2048
- qpi_score = int(mean([r['result']['score'] for r in section_results]) * standard_score)
+ qpi_score = int(mean([r['score'] for r in section_results]) * standard_score)
results = {
- 'spec': qpi_spec,
'score': qpi_score,
- 'section_results': section_results,
- 'metrics': metrics
+ 'name': qpi_spec['name'],
+ 'description': qpi_spec['description'],
+ 'children': section_results,
+ 'details': {
+ 'metrics': metrics,
+ 'spec': "https://git.opnfv.org/qtip/tree/resources/QPI/compute.yaml"
+ }
}
return results
@@ -78,13 +82,15 @@ def calc_section(section_spec, metrics):
display.vvv("spec: {}".format(section_spec))
display.vvv("metrics: {}".format(metrics))
- metric_results = [{'name': m['name'], 'result': calc_metric(m, metrics[m['name']])}
+ metric_results = [calc_metric(m, metrics[m['name']])
for m in section_spec['metrics']]
# TODO(yujunz): use formula in spec
- section_score = mean([r['result']['score'] for r in metric_results])
+ section_score = mean([r['score'] for r in metric_results])
return {
'score': section_score,
- 'metric_results': metric_results
+ 'name': section_spec['name'],
+ 'description': section_spec.get('description', 'section'),
+ 'children': metric_results
}
@@ -95,12 +101,16 @@ def calc_metric(metric_spec, metrics):
display.vvv("metrics: {}".format(metrics))
# TODO(yujunz): use formula in spec
- workload_results = [{'name': w['name'], 'score': calc_score(metrics[w['name']], w['baseline'])}
+ workload_results = [{'name': w['name'],
+ 'description': 'workload',
+ 'score': calc_score(metrics[w['name']], w['baseline'])}
for w in metric_spec['workloads']]
metric_score = mean([r['score'] for r in workload_results])
return {
'score': metric_score,
- 'workload_results': workload_results
+ 'name': metric_spec['name'],
+ 'description': metric_spec.get('description', 'metric'),
+ 'children': workload_results
}
diff --git a/qtip/cli/commands/cmd_plan.py b/qtip/cli/commands/cmd_plan.py
deleted file mode 100644
index b7c540b7..00000000
--- a/qtip/cli/commands/cmd_plan.py
+++ /dev/null
@@ -1,69 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 taseer94@gmail.com and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-
-import click
-from colorama import Fore
-import os
-
-from qtip.base.error import InvalidContentError
-from qtip.base.error import NotFoundError
-from qtip.cli import utils
-from qtip.cli.entry import Context
-from qtip.loader.plan import Plan
-
-
-pass_context = click.make_pass_decorator(Context, ensure=False)
-
-
-@click.group()
-@pass_context
-def cli(ctx):
- ''' Bechmarking Plan '''
- pass
-
-
-@cli.command('init', help='Initialize Environment')
-@pass_context
-def init(ctx):
- pass
-
-
-@cli.command('list', help='List the Plans')
-@pass_context
-def list(ctx):
- plans = Plan.list_all()
- table = utils.table('Plans', plans)
- click.echo(table)
-
-
-@cli.command('show', help='View details of a Plan')
-@click.argument('name')
-@pass_context
-def show(ctx, name):
- try:
- plan = Plan('{}.yaml'.format(name))
- except NotFoundError as nf:
- click.echo(Fore.RED + "ERROR: plan spec: " + nf.message)
- except InvalidContentError as ice:
- click.echo(Fore.RED + "ERROR: plan spec: " + ice.message)
- else:
- cnt = plan.content
- output = utils.render('plan', cnt)
- click.echo(output)
-
-
-@cli.command('run', help='Execute a Plan')
-@click.argument('name')
-@click.option('-p', '--path', help='Path to store results')
-@pass_context
-def run(ctx, name, path):
- runner_path = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
- 'runner/runner.py')
- os.system('python {0} -b all -d {1}'.format(runner_path, path))
diff --git a/qtip/cli/commands/cmd_project.py b/qtip/cli/commands/cmd_project.py
index 740fb1c4..f7ac3a83 100644
--- a/qtip/cli/commands/cmd_project.py
+++ b/qtip/cli/commands/cmd_project.py
@@ -39,12 +39,22 @@ def cli():
@cli.command(help="Create new testing project")
-@click.option('--pod', default='unknown', help='Name of pod under test')
-@click.option('--installer', help='OPNFV installer', default='manual')
-@click.option('--master-host', help='Installer hostname', default='dummy-host')
-@click.option('--scenario', default='unknown', help='OPNFV scenario')
+@click.option('--template',
+ prompt='Choose project template',
+ type=click.Choice(['compute', 'doctor']),
+ default='compute',
+ help='Choose project template')
+@click.option('--pod', default='unknown', prompt='Pod Name',
+ help='Name of pod under test')
+@click.option('--installer', prompt='OPNFV Installer',
+ help='OPNFV installer', default='manual')
+@click.option('--master-host', prompt='Installer Hostname',
+ help='Installer hostname', default='dummy-host')
+@click.option('--scenario', prompt='OPNFV Scenario', default='unknown',
+ help='OPNFV scenario')
@click.argument('name')
-def create(pod, installer, master_host, scenario, name):
+def create(pod, installer, master_host, scenario, name, template):
+ qtip_generator_role = os.path.join(utils.QTIP_ANSIBLE_ROLES, 'qtip-generator')
extra_vars = {
'qtip_package': utils.QTIP_PACKAGE,
'cwd': os.getcwd(),
@@ -52,14 +62,16 @@ def create(pod, installer, master_host, scenario, name):
'installer': installer,
'scenario': scenario,
'installer_master_host': master_host,
- 'workspace': name
+ 'project_name': name,
+ 'project_template': template
}
- os.system("ANSIBLE_ROLES_PATH={qtip_package}/{roles_path} ansible-playbook"
- " -i {qtip_package}/{roles_path}/qtip-workspace/hosts"
- " {qtip_package}/{roles_path}/qtip-workspace/create.yml"
+ os.system("ANSIBLE_ROLES_PATH={roles_path} ansible-playbook"
+ " -i {hosts}"
+ " {playbook}"
" --extra-vars '{extra_vars}'"
- "".format(qtip_package=utils.QTIP_PACKAGE,
- roles_path=utils.ROLES_PATH,
+ "".format(roles_path=utils.QTIP_ANSIBLE_ROLES,
+ hosts=os.path.join(qtip_generator_role, 'hosts'),
+ playbook=os.path.join(qtip_generator_role, 'main.yml'),
extra_vars=utils.join_vars(**extra_vars)))
diff --git a/qtip/cli/utils.py b/qtip/cli/utils.py
index 832e5ba9..0f0e7e95 100644
--- a/qtip/cli/utils.py
+++ b/qtip/cli/utils.py
@@ -15,7 +15,7 @@ from prettytable import PrettyTable
QTIP_PACKAGE = path.join(path.dirname(__file__), os.pardir, os.pardir)
-ROLES_PATH = 'resources/ansible_roles'
+QTIP_ANSIBLE_ROLES = path.join(QTIP_PACKAGE, 'resources', 'ansible_roles')
def join_vars(**kwargs):