Beautify the argument names 91/35791/2
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Mon, 5 Jun 2017 13:51:51 +0000 (21:51 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Mon, 5 Jun 2017 15:46:33 +0000 (23:46 +0800)
- 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>
qtip/cli/commands/cmd_project.py
qtip/cli/utils.py
resources/ansible_roles/qtip-generator/defaults/main.yml
resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
resources/ansible_roles/qtip-generator/files/compute/hosts
resources/ansible_roles/qtip-generator/files/compute/setup.yml
resources/ansible_roles/qtip-generator/files/compute/templates/hosts
resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg
resources/ansible_roles/qtip/tasks/generate-inventory.yml
tests/ci/run_ci.sh

index f7ac3a8..b32e71c 100644 (file)
@@ -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}"
index 0f0e7e9..331d200 100644 (file)
@@ -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):
index 846b516..527da6f 100644 (file)
@@ -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
index 3d41e1b..8b90b49 100644 (file)
@@ -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 }}"
index 9a5f831..0347e45 100644 (file)
@@ -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::
index d165a9f..d1ab263 100644 (file)
 # 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 }
index 34e4aa9..4992000 100644 (file)
@@ -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
index 6724605..f0e33fd 100644 (file)
@@ -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
index f19b044..aee2526 100644 (file)
@@ -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
index fa2f2e3..03d9d84 100644 (file)
@@ -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/