Implement qtip workspace create 87/33787/14
authorTaseer <taseer94@gmail.com>
Tue, 25 Apr 2017 12:18:27 +0000 (17:18 +0500)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Sun, 7 May 2017 10:23:08 +0000 (18:23 +0800)
Change-Id: Ibd4213a6c4c86a7f4e8f99b16cba5055a3abba39
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
qtip/cli/commands/cmd_run.py [new file with mode: 0644]
qtip/cli/commands/cmd_setup.py [new file with mode: 0644]
qtip/cli/commands/cmd_workspace.py [new file with mode: 0644]
qtip/cli/utils.py
resources/ansible_roles/qtip-workspace/ansible.cfg [moved from tests/integration/ansible.cfg with 100% similarity]
resources/ansible_roles/qtip-workspace/create.yml [moved from tests/integration/workspace-create.yml with 96% similarity]
resources/ansible_roles/qtip-workspace/hosts [moved from tests/integration/hosts with 100% similarity]
resources/ansible_roles/qtip-workspace/tasks/main.yml

diff --git a/qtip/cli/commands/cmd_run.py b/qtip/cli/commands/cmd_run.py
new file mode 100644 (file)
index 0000000..d1b96d4
--- /dev/null
@@ -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 (file)
index 0000000..586a4a7
--- /dev/null
@@ -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 (file)
index 0000000..9636f7f
--- /dev/null
@@ -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)))
index a747323..832e5ba 100644 (file)
@@ -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])
similarity index 96%
rename from tests/integration/workspace-create.yml
rename to resources/ansible_roles/qtip-workspace/create.yml
index 741d1df..66a8cf3 100644 (file)
@@ -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
 
index 4331468..4fa6006 100644 (file)
@@ -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'