summaryrefslogtreecommitdiffstats
path: root/qtip
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-05-24 19:57:27 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-05-25 15:43:53 +0800
commit8e0b0132a11dc94415054793d7b74215a75ac2d8 (patch)
tree2d7d71f87bf322f2d8088222724c0b1cd052dc6f /qtip
parent00d8896a9b19ac063f31d117c0d04ccc542eeec4 (diff)
Add support for create new project from different templates
Change-Id: Ic260c59b12eb9882406d6172311f2e401963c64b Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'qtip')
-rw-r--r--qtip/cli/commands/cmd_project.py22
-rw-r--r--qtip/cli/utils.py2
2 files changed, 16 insertions, 8 deletions
diff --git a/qtip/cli/commands/cmd_project.py b/qtip/cli/commands/cmd_project.py
index 117330f5..eefabfc0 100644
--- a/qtip/cli/commands/cmd_project.py
+++ b/qtip/cli/commands/cmd_project.py
@@ -36,6 +36,11 @@ def cli():
@cli.command(help="Create new testing project")
+@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',
@@ -45,7 +50,8 @@ def cli():
@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(),
@@ -53,14 +59,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):