vmware: refactoring of vmware test roles -- part3

Refactoring of the following roles to make use of the new
`prepare_vmware_tests` role.

- `vmware_drs_group`
- `vmware_drs_group_facts`
- `vmware_drs_rule_facts`
- `vmware_drs_portgroup`
- `vmware_drs_portgroup_facts`
- `vmware_dvs_portgroup_facts`
- `vmware_dvswitch`
- `vmware_dvswitch_pvlans`

This patch depends on: https://github.com/ansible/ansible/pull/55719

Original PR: https://github.com/ansible/ansible/pull/54882
This commit is contained in:
Gonéri Le Bouder 2019-04-24 13:52:48 -04:00
parent 636f8cbdab
commit 2307797a76
17 changed files with 326 additions and 610 deletions

View file

@ -15,6 +15,8 @@
when: setup_virtualmachines is defined when: setup_virtualmachines is defined
- include_tasks: setup_switch.yml - include_tasks: setup_switch.yml
when: setup_switch is defined when: setup_switch is defined
- include_tasks: setup_dvswitch.yml
when: setup_dvswitch is defined
- when: vcsim is defined - when: vcsim is defined

View file

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

View file

@ -2,39 +2,22 @@
# Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com> # Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}" vars:
port: 5000 setup_attach_host: true
state: started setup_datastore: true
setup_virtualmachines: true
- name: Kill vcsim - name: Create DRS VM group
uri:
url: http://{{ vcsim }}:5000/killall
- name: Start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: "Create DRS VM group"
vmware_drs_group: vmware_drs_group:
# Login creds hostname: "{{ vcenter_hostname }}"
hostname: "{{ vcsim }}" username: "{{ vcenter_username }}"
username: "{{ vcsim_instance['json']['username'] }}" password: "{{ vcenter_password }}"
password: "{{ vcsim_instance['json']['password'] }}"
validate_certs: False validate_certs: False
# Options # Options
cluster_name: DC0_C0 cluster_name: '{{ ccr1 }}'
datacenter_name: DC0 datacenter_name: '{{ dc1 }}'
group_name: TEST_VM_01 group_name: TEST_VM_01
vms: vms:
- DC0_C0_RP0_VM0 - DC0_C0_RP0_VM0
@ -42,53 +25,53 @@
state: present state: present
register: drs_vm_group_01_results register: drs_vm_group_01_results
- debug: var=drs_vm_group_01_results - debug:
var: drs_vm_group_01_results
- assert: - assert:
that: that:
- "drs_vm_group_01_results.changed" - "drs_vm_group_01_results.changed"
- name: "Create DRS Host group" - when: vcsim is defined or groups['esxi-lab'] | length >= 3
vmware_drs_group: block:
# Login creds - name: Create DRS Host group
hostname: "{{ vcsim }}" vmware_drs_group:
username: "{{ vcsim_instance['json']['username'] }}" hostname: "{{ vcenter_hostname }}"
password: "{{ vcsim_instance['json']['password'] }}" username: "{{ vcenter_username }}"
validate_certs: False password: "{{ vcenter_password }}"
# Options validate_certs: False
cluster_name: DC0_C0 cluster_name: '{{ ccr1 }}'
datacenter_name: DC0 datacenter_name: '{{ dc1 }}'
group_name: TEST_HOST_01 group_name: TEST_HOST_01
hosts: hosts: "{{ groups['esxi-lab'][0:3] }}"
- DC0_C0_H0 state: present
- DC0_C0_H1 register: drs_host_group_01_results
- DC0_C0_H2
state: present
register: drs_host_group_01_results
- debug: var=drs_host_group_01_results - debug:
var: drs_host_group_01_results
- assert: - assert:
that: that:
- "drs_host_group_01_results.changed" - "drs_host_group_01_results.changed"
- name: "Delete DRS Host group" - name: Delete DRS Host group
vmware_drs_group: vmware_drs_group:
# Login creds # Login creds
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
validate_certs: False validate_certs: False
# Options # Options
cluster_name: DC0_C0 cluster_name: DC0_C0
datacenter_name: DC0 datacenter_name: DC0
group_name: TEST_HOST_01 group_name: TEST_HOST_01
hosts: [] hosts: []
state: absent state: absent
register: drs_host_group_01_delete_results register: drs_host_group_01_delete_results
- debug: var=drs_host_group_01_delete_results - debug:
var: drs_host_group_01_delete_results
- assert: - assert:
that: that:
- "drs_host_group_01_delete_results.changed" - "drs_host_group_01_delete_results.changed"

View file

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

View file

@ -2,59 +2,43 @@
# Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com> # Copyright: (c) 2018, Karsten Kaj Jakobsen <kj@patientsky.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim - when: vcsim is defined or groups['esxi-lab'] | length >= 3
uri: block:
url: http://{{ vcsim }}:5000/killall - name: Gather DRS group facts from given cluster
vmware_drs_group_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: '{{ ccr1 }}'
validate_certs: False
register: drs_group_0001_results
- name: start vcsim - debug:
uri: var: drs_group_0001_results
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for Flask controller to come up online - assert:
wait_for: that:
host: "{{ vcsim }}" - "drs_group_0001_results.drs_group_facts.DC0_C0 is defined"
port: 443 - "not drs_group_0001_results.drs_group_facts.DC0_C1 is defined"
state: started - "not drs_group_0001_results.changed"
- debug: var=vcsim_instance - name: Gather DRS group facts from given datacenter
vmware_drs_group_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: '{{ dc1 }}'
validate_certs: False
register: drs_group_0002_results
- name: Gather DRS group facts from given cluster - debug:
vmware_drs_group_facts: var: drs_group_0002_results
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
cluster_name: DC0_C0
validate_certs: False
register: drs_group_0001_results
- debug: var=drs_group_0001_results - assert:
that:
- assert: - "drs_group_0002_results.drs_group_facts.DC0_C0 is defined"
that: - "not drs_group_0002_results.drs_group_facts.DC0_C1 is defined"
- "drs_group_0001_results.drs_group_facts.DC0_C0 is defined" - "not drs_group_0002_results.changed"
- "not drs_group_0001_results.drs_group_facts.DC0_C1 is defined"
- "not drs_group_0001_results.changed"
- name: Gather DRS group facts from given datacenter
vmware_drs_group_facts:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: DC0
validate_certs: False
register: drs_group_0002_results
- debug: var=drs_group_0002_results
- assert:
that:
- "drs_group_0002_results.drs_group_facts.DC0_C0 is defined"
- "drs_group_0002_results.drs_group_facts.DC0_C1 is defined"
- "not drs_group_0002_results.changed"

View file

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

View file

@ -2,56 +2,43 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - when: vcsim is defined or groups['esxi-lab'] | length >= 3
wait_for: block:
host: "{{ vcsim }}" - import_role:
port: 5000 name: prepare_vmware_tests
state: started vars:
setup_attach_host: true
- name: kill vcsim - name: Gather facts about DRS rule from given cluster
uri: vmware_drs_rule_facts:
url: http://{{ vcsim }}:5000/killall validate_certs: False
- name: start vcsim hostname: "{{ vcenter_hostname }}"
uri: username: "{{ vcenter_username }}"
url: http://{{ vcsim }}:5000/spawn?cluster=2 password: "{{ vcenter_password }}"
register: vcsim_instance cluster_name: DC0_C0
register: drs_rule_0001_results
- name: Wait for Flask controller to come up online - debug:
wait_for: var: drs_rule_0001_results
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance - assert:
that:
- "drs_rule_0001_results.drs_rule_facts is defined"
- "not drs_rule_0001_results.changed"
- name: Gather facts about DRS rule from given cluster - name: Gather facts about DRS rule from given datacenter
vmware_drs_rule_facts: vmware_drs_rule_facts:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
cluster_name: DC0_C0 datacenter: DC0
register: drs_rule_0001_results register: drs_rule_0001_results
- debug: var=drs_rule_0001_results - debug:
var: drs_rule_0001_results
- assert: - assert:
that: that:
- "drs_rule_0001_results.drs_rule_facts is defined" - "drs_rule_0001_results.drs_rule_facts is defined"
- "not drs_rule_0001_results.changed" - "not drs_rule_0001_results.changed"
- name: Gather facts about DRS rule from given datacenter
vmware_drs_rule_facts:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: DC0
register: drs_rule_0001_results
- debug: var=drs_rule_0001_results
- assert:
that:
- "drs_rule_0001_results.drs_rule_facts is defined"
- "not drs_rule_0001_results.changed"

View file

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

View file

@ -1,62 +1,19 @@
# Test code for the vmware_dvs_portgroup module. # Test code for the vmware_dvs_portgroup module.
# (c) 2017, Philippe Dellaert <philippe@dellaert.org> # Copyright: (c) 2017, Philippe Dellaert <philippe@dellaert.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible - import_role:
# name: prepare_vmware_tests
# Ansible is free software: you can redistribute it and/or modify vars:
# it under the terms of the GNU General Public License as published by setup_dvswitch: true
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/killall' }}"
- name: start vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/spawn?cluster=2' }}"
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- debug: var=vcsim_instance
- name: get a list of distributed vswitch from vcsim after adding
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=DVS' }}"
register: new_dvs_0001
- debug:
msg: "{{ item | basename }}"
with_items: "{{ new_dvs_0001['json'] }}"
# Testcase 0001: Add basic portgroup
- name: create basic portgroup - name: create basic portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic" portgroup_name: "basic"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -64,19 +21,21 @@
state: present state: present
register: dvs_pg_result_0001 register: dvs_pg_result_0001
- debug:
var: dvs_pg_result_0001
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0001.changed == true }}" - dvs_pg_result_0001.changed
# Testcase 0002: Add basic VLAN portgroup
- name: create basic VLAN portgroup - name: create basic VLAN portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic-vlan10" portgroup_name: "basic-vlan10"
vlan_id: 10 vlan_id: 10
num_ports: 32 num_ports: 32
@ -87,16 +46,15 @@
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0002.changed == true }}" - dvs_pg_result_0002.changed
# Testcase 0003: Add basic trunk portgroup
- name: create basic trunk portgroup - name: create basic trunk portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic-trunk" portgroup_name: "basic-trunk"
vlan_id: 1-4094 vlan_id: 1-4094
vlan_trunk: True vlan_trunk: True
@ -108,16 +66,15 @@
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0003.changed == true }}" - dvs_pg_result_0003.changed
# Testcase 0004: Add basic portgroup again
- name: create basic portgroup again - name: create basic portgroup again
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic" portgroup_name: "basic"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -128,16 +85,15 @@
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0004.changed == false }}" - not dvs_pg_result_0004.changed
# Testcase 0005: Add basic portgroup with all security and policy settings enabled
- name: create basic portgroup with all security and policy settings enabled - name: create basic portgroup with all security and policy settings enabled
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic-all-enabled" portgroup_name: "basic-all-enabled"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -164,16 +120,15 @@
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0005.changed == true }}" - dvs_pg_result_0005.changed
# Testcase 0006: Add basic portgroup with some settings enabled
- name: create basic portgroup with all security and policy settings enabled - name: create basic portgroup with all security and policy settings enabled
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic-some-enabled" portgroup_name: "basic-some-enabled"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -190,16 +145,15 @@
- name: ensure dvs portgroup is present - name: ensure dvs portgroup is present
assert: assert:
that: that:
- "{{ dvs_pg_result_0006.changed == true }}" - dvs_pg_result_0006.changed
# Testcase 0007: Delete basic portgroup
- name: delete basic portgroup - name: delete basic portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic" portgroup_name: "basic"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -210,16 +164,15 @@
- name: ensure dvs portgroup is removed - name: ensure dvs portgroup is removed
assert: assert:
that: that:
- "{{ dvs_pg_result_0007.changed == true }}" - dvs_pg_result_0007.changed
# Testcase 0008: Delete basic portgroup again
- name: delete basic portgroup again - name: delete basic portgroup again
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic" portgroup_name: "basic"
vlan_id: 0 vlan_id: 0
num_ports: 32 num_ports: 32
@ -230,16 +183,15 @@
- name: ensure dvs portgroup is removed - name: ensure dvs portgroup is removed
assert: assert:
that: that:
- "{{ dvs_pg_result_0008.changed == false }}" - not dvs_pg_result_0008.changed
# Testcase 0009: Check valid VLAN id range in DVS Portgroup
- name: Check valid VLAN id range in DVS Portgroup - name: Check valid VLAN id range in DVS Portgroup
vmware_dvs_portgroup: vmware_dvs_portgroup:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch_name: "{{ new_dvs_0001['json'][0] | basename }}" switch_name: "{{ dvswitch1 }}"
portgroup_name: "basic_trunk_0001" portgroup_name: "basic_trunk_0001"
vlan_id: 1-4096 vlan_id: 1-4096
vlan_trunk: True vlan_trunk: True

View file

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

View file

@ -2,55 +2,32 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - &dvs_facts
port: 5000 name: Gather facts about DVS portgroup
state: started vmware_dvs_portgroup_facts:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
register: dvs_results
- name: kill vcsim - debug:
uri: var: dvs_results
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for Flask controller to come up online - assert:
wait_for: that:
host: "{{ vcsim }}" - dvs_results.dvs_portgroup_facts is defined
port: 443
state: started
- debug: var=vcsim_instance - <<: *dvs_facts
name: Gather facts about DVS portgroup in check mode
check_mode: yes
- name: Gather facts about DVS portgroup - debug:
vmware_dvs_portgroup_facts: var: dvs_results
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: DC0
register: dvs_results
- debug: var=dvs_results - assert:
that:
- assert: - dvs_results.dvs_portgroup_facts is defined
that:
- "dvs_results.dvs_portgroup_facts is defined"
- name: Gather facts about DVS portgroup in check mode
vmware_dvs_portgroup_facts:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter: DC0
register: dvs_results
check_mode: yes
- debug: var=dvs_results
- assert:
that:
- "dvs_results.dvs_portgroup_facts is defined"

View file

@ -1,2 +1,3 @@
shippable/vcenter/group1 shippable/vcenter/group1
cloud/vcenter cloud/vcenter
needs/target/prepare_vmware_tests

View file

@ -2,43 +2,18 @@
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- debug: var=vcsim_instance
- debug: var=datacenters
# Testcase 0001: Add Distributed vSwitch # Testcase 0001: Add Distributed vSwitch
- name: add distributed vSwitch - &dvs_data
name: add distributed vSwitch
vmware_dvswitch: vmware_dvswitch:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter_name: "{{ item | basename }}" datacenter_name: "{{ dc1 }}"
state: present state: present
switch_name: dvswitch_0001 switch_name: dvswitch_0001
mtu: 9000 mtu: 9000
@ -46,95 +21,43 @@
discovery_proto: lldp discovery_proto: lldp
discovery_operation: both discovery_operation: both
register: dvs_result_0001 register: dvs_result_0001
with_items:
- "{{ datacenters['json'] }}"
- name: ensure distributed vswitch is present - name: ensure distributed vswitch is present
assert: assert:
that: that:
- "{{ dvs_result_0001.changed == true }}" - dvs_result_0001.changed
- name: get a list of distributed vswitch from vcsim after adding
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DVS
register: new_dvs_0001
- debug:
msg: "{{ item | basename }}"
with_items: "{{ new_dvs_0001['json'] }}"
- set_fact: new_dvs_name="{% for dvs in new_dvs_0001['json'] %} {{ True if (dvs | basename) == 'dvswitch_0001' else False }}{% endfor %}"
- debug: var=new_dvs_name
- assert:
that:
- "{{ 'True' in new_dvs_name }}"
# Testcase 0002: Add Distributed vSwitch again # Testcase 0002: Add Distributed vSwitch again
# vcsim doesn't support ldp check (self.dvs.config.linkDiscoveryProtocolConfig.protocol) # vcsim doesn't support ldp check (self.dvs.config.linkDiscoveryProtocolConfig.protocol)
# - name: add distributed vSwitch again - when: vcsim is not defined
# vmware_dvswitch: block:
# validate_certs: False - <<: *dvs_data
# hostname: "{{ vcsim }}" name: add distributed vSwitch again
# username: "{{ vcsim_instance['json']['username'] }}" register: dvs_result_0002
# password: "{{ vcsim_instance['json']['password'] }}"
# datacenter_name: "{{ item | basename }}" - name: ensure distributed vswitch is present
# state: present assert:
# switch_name: dvswitch_0001 that:
# mtu: 9000 - not dvs_result_0002.changed
# uplink_quantity: 2
# discovery_proto: lldp
# discovery_operation: both
# register: dvs_result_0002
# with_items:
# - "{{ datacenters['json'] }}"
#
# - name: ensure distributed vswitch is present
# assert:
# that:
# - "{{ dvs_result_0002.changed == false }}"
# FIXME: Uncomment this testcase once vcsim supports distributed vswitch delete method # FIXME: Remove this testcase from block once vcsim supports distributed vswitch delete method
# Currently, vcsim does not support distributed vswitch delete option, # Currently, vcsim does not support distributed vswitch delete option,
# Once this feature is available we can uncomment following testcase # Once this feature is available we can move this out of this block
# Testcase 0003: Add Distributed vSwitch # Testcase 0003: Add Distributed vSwitch
#- name: add distributed vSwitch - name: delete the distributed vSwitch
# vmware_dvswitch: vmware_dvswitch:
# validate_certs: False validate_certs: False
# hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
# username: root username: "{{ vcenter_username }}"
# password: esxi@123 password: "{{ vcenter_password }}"
# datacenter_name: "{{ item | basename }}" datacenter_name: "{{ dc1 }}"
# state: absent state: absent
# switch_name: dvswitch_0001 switch_name: dvswitch_0001
# mtu: 9000 register: dvs_result_0003
# uplink_quantity: 2
# discovery_proto: lldp
# discovery_operation: both
# with_items:
# - "{{ datacenters['json'] }}"
# register: dvs_result_0003
#- name: ensure distributed vswitch is present - name: ensure distributed vswitch is present
# assert: assert:
# that: that:
# - "{{ dvs_result_0003.changed == true }}" - dvs_result_0003.changed
#- name: get a list of Datacenter from vcsim after adding datacenter
# uri:
# url: http://{{ vcsim }}:5000/govc_find?filter=DVS
# register: del_dvs
#- debug:
# msg: "{{ item | basename }}"
# with_items: "{{ del_dvs['json'] }}"
#- set_fact: del_dvs_name="{% for i in del_dvs['json'] %} {{ True if (i | basename) == 'dvswitch_0001' else False }}{% endfor %}"
#- debug: var=del_dvs_name
#- assert:
# that:
# - "{{ 'True' not in del_dvs_name }}"

View file

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

View file

@ -2,43 +2,17 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- debug: var=vcsim_instance
- debug: var=datacenters
# Testcase 0001: Add Distributed vSwitch # Testcase 0001: Add Distributed vSwitch
- name: add distributed vSwitch - name: add distributed vSwitch
vmware_dvswitch: vmware_dvswitch:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter_name: "{{ item | basename }}" datacenter_name: "{{ dc1 }}"
state: present state: present
switch_name: dvswitch_0001 switch_name: dvswitch_0001
mtu: 9000 mtu: 9000
@ -46,63 +20,21 @@
discovery_proto: lldp discovery_proto: lldp
discovery_operation: both discovery_operation: both
register: dvs_result_0001 register: dvs_result_0001
with_items:
- "{{ datacenters['json'] }}" - debug:
var: dvs_result_0001
- name: ensure distributed vswitch is present - name: ensure distributed vswitch is present
assert: assert:
that: that:
- "{{ dvs_result_0001.changed == true }}" - dvs_result_0001 is changed
- name: get a list of distributed vswitch from vcsim after adding - &pv_data
uri: name: Configure PVLANs
url: http://{{ vcsim }}:5000/govc_find?filter=DVS
register: new_dvs_0001
- debug:
msg: "{{ item | basename }}"
with_items: "{{ new_dvs_0001['json'] }}"
- set_fact: new_dvs_name="{% for dvs in new_dvs_0001['json'] %} {{ True if (dvs | basename) == 'dvswitch_0001' else False }}{% endfor %}"
- debug: var=new_dvs_name
- assert:
that:
- "{{ 'True' in new_dvs_name }}"
- name: Configure PVLANs in check mode
vmware_dvswitch_pvlans: vmware_dvswitch_pvlans:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
switch: dvswitch_0001
primary_pvlans:
- primary_pvlan_id: 1
- primary_pvlan_id: 4
secondary_pvlans:
- primary_pvlan_id: 1
secondary_pvlan_id: 2
pvlan_type: isolated
- primary_pvlan_id: 1
secondary_pvlan_id: 3
pvlan_type: community
- primary_pvlan_id: 4
secondary_pvlan_id: 5
pvlan_type: community
validate_certs: no
register: pvlans_result_check_mode
check_mode: yes
- name: ensure pvlans were configured
assert:
that:
- pvlans_result_check_mode.changed
- name: Configure PVLANs
vmware_dvswitch_pvlans:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
switch: dvswitch_0001 switch: dvswitch_0001
primary_pvlans: primary_pvlans:
- primary_pvlan_id: 1 - primary_pvlan_id: 1
@ -120,7 +52,23 @@
validate_certs: no validate_certs: no
register: pvlans_result register: pvlans_result
- debug:
var: pvlans_result
- name: ensure pvlans were configured - name: ensure pvlans were configured
assert: assert:
that: that:
- pvlans_result.changed - pvlans_result is changed
- <<: *pv_data
name: Configure PVLANs in check mode
register: pvlans_result_check_mode
check_mode: yes
- debug:
var: pvlans_result_check_mode
- name: ensure pvlans were configured
assert:
that:
- pvlans_result_check_mode is changed

View file

@ -1,2 +1,3 @@
cloud/vcenter cloud/vcenter
unsupported shippable/vcenter/group1
needs/target/prepare_vmware_tests

View file

@ -2,43 +2,17 @@
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de> # Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online - import_role:
wait_for: name: prepare_vmware_tests
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of Datacenter from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- debug: var=vcsim_instance
- debug: var=datacenters
# Testcase 0001: Add Distributed vSwitch # Testcase 0001: Add Distributed vSwitch
- name: add distributed vSwitch - name: add distributed vSwitch
vmware_dvswitch: vmware_dvswitch:
validate_certs: False validate_certs: False
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance['json']['username'] }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance['json']['password'] }}" password: "{{ vcenter_password }}"
datacenter_name: "{{ item | basename }}" datacenter_name: "{{ dc1 }}"
state: present state: present
switch_name: dvswitch_0001 switch_name: dvswitch_0001
mtu: 9000 mtu: 9000
@ -46,77 +20,55 @@
discovery_proto: lldp discovery_proto: lldp
discovery_operation: both discovery_operation: both
register: dvs_result_0001 register: dvs_result_0001
with_items:
- "{{ datacenters['json'] }}" - debug:
var: dvs_result_0001
- name: ensure distributed vswitch is present - name: ensure distributed vswitch is present
assert: assert:
that: that:
- "{{ dvs_result_0001.changed == true }}" - dvs_result_0001 is changed
- name: get a list of distributed vswitch from vcsim after adding - when: vcsim is not defined
uri: block:
url: http://{{ vcsim }}:5000/govc_find?filter=DVS - &uplink_data
register: new_dvs_0001 name: Configure Uplink portgroup in check mode
vmware_dvswitch_uplink_pg:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
switch: dvswitch_0001
name: dvswitch_0001-DVUplinks
advanced:
port_config_reset_at_disconnect: False
block_override: False
vendor_config_override: False
vlan_override: False
netflow_override: False
traffic_filter_override: False
vlan_trunk_range: [ 2-3967, 4049-4092 ]
netflow_enabled: True
block_all_ports: False
validate_certs: no
register: uplink_pg_result_check_mode
check_mode: yes
- debug: - debug:
msg: "{{ item | basename }}" var: uplink_pg_result_check_mode
with_items: "{{ new_dvs_0001['json'] }}"
- set_fact: new_dvs_name="{% for dvs in new_dvs_0001['json'] %} {{ True if (dvs | basename) == 'dvswitch_0001' else False }}{% endfor %}" - name: ensure uplink portgroup was changed
assert:
that:
- uplink_pg_result_check_mode is changed
- debug: var=new_dvs_name - <<: *uplink_data
- assert: name: Configure Uplink portgroup
that: check_mode: no
- "{{ 'True' in new_dvs_name }}"
- name: Configure Uplink portgroup in check mode - debug:
vmware_dvswitch_uplink_pg: var: uplink_pg_result
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
switch: dvswitch_0001
name: dvswitch_0001-DVUplinks
advanced:
port_config_reset_at_disconnect: False
block_override: False
vendor_config_override: False
vlan_override: False
netflow_override: False
traffic_filter_override: False
vlan_trunk_range: [ 2-3967, 4049-4092 ]
netflow_enabled: True
block_all_ports: False
validate_certs: no
register: uplink_pg_result_check_mode
check_mode: yes
- name: ensure uplink portgroup was changed - name: ensure uplink portgroup was changed
assert: assert:
that: that:
- uplink_pg_result_check_mode.changed - uplink_pg_result is changed
- name: Configure Uplink portgroup
vmware_dvswitch_uplink_pg:
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
switch: dvswitch_0001
name: dvswitch_0001-DVUplinks
advanced:
port_config_reset_at_disconnect: False
block_override: False
vendor_config_override: False
vlan_override: False
netflow_override: False
traffic_filter_override: False
vlan_trunk_range: [ 2-3967, 4049-4092 ]
netflow_enabled: True
block_all_ports: False
validate_certs: no
register: uplink_pg_result
- name: ensure uplink portgroup was changed
assert:
that:
- uplink_pg_result.changed