aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-05-08 06:28:34 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-05-08 06:28:34 +0000
commit28769eb7866a0fd362dd68e9ea545a82f136c679 (patch)
treef241554361ee8b45d36e7ee2d3ac917a917bb9ff
parentf25075b0dd2656efd1daae10c4739f029788c83f (diff)
parentebf4e585a6bbc7a08c5e779ff9863436e44484d8 (diff)
Merge "Implement qtip workspace create"
-rw-r--r--qtip/cli/commands/cmd_run.py16
-rw-r--r--qtip/cli/commands/cmd_setup.py16
-rw-r--r--qtip/cli/commands/cmd_workspace.py34
-rw-r--r--qtip/cli/utils.py9
-rw-r--r--resources/ansible_roles/qtip-workspace/ansible.cfg (renamed from tests/integration/ansible.cfg)0
-rw-r--r--resources/ansible_roles/qtip-workspace/create.yml (renamed from tests/integration/workspace-create.yml)2
-rw-r--r--resources/ansible_roles/qtip-workspace/hosts (renamed from tests/integration/hosts)0
-rw-r--r--resources/ansible_roles/qtip-workspace/tasks/main.yml4
8 files changed, 78 insertions, 3 deletions
diff --git a/qtip/cli/commands/cmd_run.py b/qtip/cli/commands/cmd_run.py
new file mode 100644
index 00000000..d1b96d4f
--- /dev/null
+++ b/qtip/cli/commands/cmd_run.py
@@ -0,0 +1,16 @@
+##############################################################################
+# Copyright (c) 2017 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
+
+
+@click.command('run', help='Run performance tests')
+def cli():
+ pass
diff --git a/qtip/cli/commands/cmd_setup.py b/qtip/cli/commands/cmd_setup.py
new file mode 100644
index 00000000..586a4a72
--- /dev/null
+++ b/qtip/cli/commands/cmd_setup.py
@@ -0,0 +1,16 @@
+##############################################################################
+# Copyright (c) 2017 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
+
+
+@click.command('setup', help='Setup QTIP workspace')
+def cli():
+ pass
diff --git a/qtip/cli/commands/cmd_workspace.py b/qtip/cli/commands/cmd_workspace.py
new file mode 100644
index 00000000..9636f7fb
--- /dev/null
+++ b/qtip/cli/commands/cmd_workspace.py
@@ -0,0 +1,34 @@
+##############################################################################
+# Copyright (c) 2017 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
+import os
+
+from qtip.cli import utils
+
+
+@click.group()
+def cli():
+ """ Manage QTIP workspace """
+ pass
+
+
+@cli.command("create", help="Create QTIP workspace")
+def create():
+ extra_vars = {
+ 'qtip_package': utils.QTIP_PACKAGE,
+ 'cwd': os.getcwd()
+ }
+ os.system("ANSIBLE_ROLES_PATH={qtip_package}/{roles_path} ansible-playbook"
+ " {qtip_package}/{roles_path}/qtip-workspace/create.yml"
+ " --extra-vars '{extra_vars}'"
+ "".format(qtip_package=utils.QTIP_PACKAGE,
+ roles_path=utils.ROLES_PATH,
+ extra_vars=utils.join_vars(**extra_vars)))
diff --git a/qtip/cli/utils.py b/qtip/cli/utils.py
index a7473236..832e5ba9 100644
--- a/qtip/cli/utils.py
+++ b/qtip/cli/utils.py
@@ -9,10 +9,19 @@
from jinja2 import Environment
from jinja2 import FileSystemLoader
+import os
from os import path
from prettytable import PrettyTable
+QTIP_PACKAGE = path.join(path.dirname(__file__), os.pardir, os.pardir)
+ROLES_PATH = 'resources/ansible_roles'
+
+
+def join_vars(**kwargs):
+ return " ".join(["{}={}".format(variable, value) for variable, value in kwargs.items()])
+
+
def table(name, components):
""" Return a PrettyTable for component listing """
table = PrettyTable([name])
diff --git a/tests/integration/ansible.cfg b/resources/ansible_roles/qtip-workspace/ansible.cfg
index 74075909..74075909 100644
--- a/tests/integration/ansible.cfg
+++ b/resources/ansible_roles/qtip-workspace/ansible.cfg
diff --git a/tests/integration/workspace-create.yml b/resources/ansible_roles/qtip-workspace/create.yml
index 741d1df0..66a8cf36 100644
--- a/tests/integration/workspace-create.yml
+++ b/resources/ansible_roles/qtip-workspace/create.yml
@@ -25,7 +25,7 @@
private: no
- name: installer
- prompt: 'installer type of the pod (apex|fuel|other)'
+ prompt: 'installer type of the pod (apex|fuel)'
default: fuel
private: no
diff --git a/tests/integration/hosts b/resources/ansible_roles/qtip-workspace/hosts
index 2302edae..2302edae 100644
--- a/tests/integration/hosts
+++ b/resources/ansible_roles/qtip-workspace/hosts
diff --git a/resources/ansible_roles/qtip-workspace/tasks/main.yml b/resources/ansible_roles/qtip-workspace/tasks/main.yml
index 4331468d..4fa60061 100644
--- a/resources/ansible_roles/qtip-workspace/tasks/main.yml
+++ b/resources/ansible_roles/qtip-workspace/tasks/main.yml
@@ -9,7 +9,7 @@
- name: creating directories
file:
- path: "{{ workspace }}/{{ item.path }}"
+ path: "{{ cwd }}/{{ workspace }}/{{ item.path }}"
state: directory
force: yes
with_filetree: template/
@@ -18,7 +18,7 @@
- name: templating files
template:
src: "{{ item.src }}"
- dest: "{{ workspace }}/{{ item.path }}"
+ dest: "{{ cwd }}/{{ workspace }}/{{ item.path }}"
force: yes
with_filetree: template/
when: item.state == 'file'