aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-06-05 21:51:51 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-06-05 23:46:33 +0800
commitcb3795a39882bb97c15ae5c9562faf577334399b (patch)
tree6bbd1d366b1e214bed87398ff7a1db102c607459
parent0ce21bc2fc83faa3462de9fd52360cb0d6fae71d (diff)
Beautify the argument names
- keep the argument consisten with OPNFV convention - installer-ip is not used because in fact we use host address instead - remove optional argurment from prompt Change-Id: I3db3cf53b62cc86e143bc59a7dd8bb83d0f74b7d Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
-rw-r--r--qtip/cli/commands/cmd_project.py37
-rw-r--r--qtip/cli/utils.py2
-rw-r--r--resources/ansible_roles/qtip-generator/defaults/main.yml7
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml8
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/hosts6
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/setup.yml4
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/templates/hosts4
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg2
-rw-r--r--resources/ansible_roles/qtip/tasks/generate-inventory.yml2
-rw-r--r--tests/ci/run_ci.sh4
10 files changed, 40 insertions, 36 deletions
diff --git a/qtip/cli/commands/cmd_project.py b/qtip/cli/commands/cmd_project.py
index f7ac3a83..b32e71cd 100644
--- a/qtip/cli/commands/cmd_project.py
+++ b/qtip/cli/commands/cmd_project.py
@@ -39,31 +39,36 @@ def cli():
@cli.command(help="Create new testing project")
-@click.option('--template',
- prompt='Choose project template',
+@click.argument('project_name')
+@click.option('--project-template',
type=click.Choice(['compute', 'doctor']),
default='compute',
help='Choose project template')
-@click.option('--pod', default='unknown', prompt='Pod Name',
+@click.option('--pod-name',
+ prompt='Pod Name',
+ default='opnfv-pod',
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',
+@click.option('--installer-type',
+ type=click.Choice(['apex', 'fuel', 'manual']),
+ prompt='OPNFV Installer Type',
+ default='manual',
+ help='OPNFV installer')
+@click.option('--installer-host',
+ prompt='Installer SSH Host Address',
+ help='Host configured for ssh client or IP addresses and domain name')
+@click.option('--scenario',
help='OPNFV scenario')
-@click.argument('name')
-def create(pod, installer, master_host, scenario, name, template):
+def create(project_name, project_template, pod_name, installer_type, installer_host, scenario):
qtip_generator_role = os.path.join(utils.QTIP_ANSIBLE_ROLES, 'qtip-generator')
extra_vars = {
'qtip_package': utils.QTIP_PACKAGE,
'cwd': os.getcwd(),
- 'pod_name': pod,
- 'installer': installer,
- 'scenario': scenario,
- 'installer_master_host': master_host,
- 'project_name': name,
- 'project_template': template
+ 'project_name': project_name,
+ 'project_template': project_template,
+ 'pod_name': pod_name,
+ 'installer_type': installer_type,
+ 'installer_host': installer_host,
+ 'scenario': scenario
}
os.system("ANSIBLE_ROLES_PATH={roles_path} ansible-playbook"
" -i {hosts}"
diff --git a/qtip/cli/utils.py b/qtip/cli/utils.py
index 0f0e7e95..331d2000 100644
--- a/qtip/cli/utils.py
+++ b/qtip/cli/utils.py
@@ -19,7 +19,7 @@ QTIP_ANSIBLE_ROLES = path.join(QTIP_PACKAGE, 'resources', 'ansible_roles')
def join_vars(**kwargs):
- return " ".join(["{}={}".format(variable, value) for variable, value in kwargs.items()])
+ return " ".join(["{}={}".format(variable, value) for variable, value in kwargs.items() if value is not None])
def table(name, components):
diff --git a/resources/ansible_roles/qtip-generator/defaults/main.yml b/resources/ansible_roles/qtip-generator/defaults/main.yml
index 846b5169..527da6f7 100644
--- a/resources/ansible_roles/qtip-generator/defaults/main.yml
+++ b/resources/ansible_roles/qtip-generator/defaults/main.yml
@@ -7,11 +7,10 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-installer: fuel
+installer_type: fuel
+installer_host: fuel-master
-installer_master_host: fuel-master
-
-installer_master_group:
+installer_group:
manual: dummy-group
fuel: fuel-masters
apex: apex-underclouds
diff --git a/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml b/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
index 3d41e1b4..8b90b498 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
@@ -13,10 +13,10 @@ qtip_fixtures: fixtures
qtip_dump: dump
qtip_cache: "{{ qtip_cache }}"
qtip_workdir: "{% raw %}{{ ansible_env.HOME }}{% endraw %}/qtip-workdir-{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"
-installer_master_group:
+
+installer_type: "{{ installer_type }}"
+installer_host: "{{ installer_host }}"
+installer_group:
manual: dummy-group
fuel: fuel-masters
apex: apex-underclouds
-
-installer: "{{ installer }}"
-installer_master_host: "{{ installer_master_host }}"
diff --git a/resources/ansible_roles/qtip-generator/files/compute/hosts b/resources/ansible_roles/qtip-generator/files/compute/hosts
index 9a5f831b..0347e450 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/hosts
+++ b/resources/ansible_roles/qtip-generator/files/compute/hosts
@@ -1,8 +1,8 @@
localhost ansible_connection=local
-{% if installer != 'manual' %}
-[{{ installer_master_group[installer] }}]
-{{ installer_master_host }}
+{% if installer_type != 'manual' %}
+[{{ installer_group[installer_type] }}]
+{{ installer_host }}
{% else %}
[SUT]
# Add hosts in system under test, example::
diff --git a/resources/ansible_roles/qtip-generator/files/compute/setup.yml b/resources/ansible_roles/qtip-generator/files/compute/setup.yml
index d165a9fe..d1ab2638 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/setup.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/setup.yml
@@ -10,13 +10,13 @@
# Prepare connection to SUT (System Under Test)
---
-{% if installer == 'manual' %}
+{% if installer_type == 'manual' %}
- hosts: localhost
gather_facts: no
tasks:
- debug: "msg='please add hosts to SUT group in `hosts` file manually.'"
{% else %}
-- hosts: [{{ installer_master_group[installer] }}]
+- hosts: [{{ installer_group[installer_type] }}]
gather_facts: no
roles:
- { role: qtip, tasks: generate-inventory }
diff --git a/resources/ansible_roles/qtip-generator/files/compute/templates/hosts b/resources/ansible_roles/qtip-generator/files/compute/templates/hosts
index 34e4aa92..49920006 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/templates/hosts
+++ b/resources/ansible_roles/qtip-generator/files/compute/templates/hosts
@@ -1,8 +1,8 @@
{% raw %}
localhost ansible_connection=local
-[{{ installer_master_group[installer] }}]
-{{ installer_master_host }}
+[{{ installer_group[installer_type] }}]
+{{ installer_host }}
[SUT:children] # system under test
compute
diff --git a/resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg b/resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg
index 67246054..f0e33fd4 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg
+++ b/resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg
@@ -10,7 +10,7 @@
Host {{ name }}
HostName {{ host.ansible_ssh_host }}
User root
- ProxyCommand ssh -o 'ForwardAgent yes' {{ installer_master_host }} 'ssh-add && nc %h %p'
+ ProxyCommand ssh -o 'ForwardAgent yes' {{ installer_host }} 'ssh-add && nc %h %p'
{% endfor %}
{% endraw %} \ No newline at end of file
diff --git a/resources/ansible_roles/qtip/tasks/generate-inventory.yml b/resources/ansible_roles/qtip/tasks/generate-inventory.yml
index f19b0447..aee25260 100644
--- a/resources/ansible_roles/qtip/tasks/generate-inventory.yml
+++ b/resources/ansible_roles/qtip/tasks/generate-inventory.yml
@@ -11,7 +11,7 @@
---
-- include: "gather-facts-{{ installer }}.yml"
+- include: "gather-facts-{{ installer_type }}.yml"
- name: generating inventory file
template: src=templates/hosts dest=./hosts
diff --git a/tests/ci/run_ci.sh b/tests/ci/run_ci.sh
index fa2f2e34..03d9d846 100644
--- a/tests/ci/run_ci.sh
+++ b/tests/ci/run_ci.sh
@@ -67,8 +67,8 @@ esac
cd /home/opnfv
-qtip create --template compute --pod ${pod_name} --installer ${installer_type} \
---master-host ${installer_ip} --scenario ${scenario} workspace
+qtip create --pod-name ${pod_name} --installer-type ${installer_type} \
+--installer-host ${installer_ip} --scenario ${scenario} workspace
cd /home/opnfv/workspace/