mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
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:
@@ -1,2 +1,3 @@
|
||||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
needs/target/prepare_vmware_tests
|
||||
|
||||
@@ -2,43 +2,18 @@
|
||||
# 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)
|
||||
|
||||
- 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
|
||||
|
||||
- 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
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
|
||||
# Testcase 0001: Add Distributed vSwitch
|
||||
- name: add distributed vSwitch
|
||||
- &dvs_data
|
||||
name: add distributed vSwitch
|
||||
vmware_dvswitch:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
datacenter_name: "{{ item | basename }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
state: present
|
||||
switch_name: dvswitch_0001
|
||||
mtu: 9000
|
||||
@@ -46,95 +21,43 @@
|
||||
discovery_proto: lldp
|
||||
discovery_operation: both
|
||||
register: dvs_result_0001
|
||||
with_items:
|
||||
- "{{ datacenters['json'] }}"
|
||||
|
||||
- name: ensure distributed vswitch is present
|
||||
assert:
|
||||
that:
|
||||
- "{{ dvs_result_0001.changed == true }}"
|
||||
|
||||
- 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 }}"
|
||||
|
||||
- dvs_result_0001.changed
|
||||
|
||||
# Testcase 0002: Add Distributed vSwitch again
|
||||
# vcsim doesn't support ldp check (self.dvs.config.linkDiscoveryProtocolConfig.protocol)
|
||||
# - name: add distributed vSwitch again
|
||||
# vmware_dvswitch:
|
||||
# validate_certs: False
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: "{{ vcsim_instance['json']['username'] }}"
|
||||
# password: "{{ vcsim_instance['json']['password'] }}"
|
||||
# datacenter_name: "{{ item | basename }}"
|
||||
# state: present
|
||||
# switch_name: dvswitch_0001
|
||||
# mtu: 9000
|
||||
# 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 }}"
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- <<: *dvs_data
|
||||
name: add distributed vSwitch again
|
||||
register: dvs_result_0002
|
||||
|
||||
- name: ensure distributed vswitch is present
|
||||
assert:
|
||||
that:
|
||||
- not dvs_result_0002.changed
|
||||
|
||||
|
||||
# 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,
|
||||
# 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
|
||||
#- name: add distributed vSwitch
|
||||
# vmware_dvswitch:
|
||||
# validate_certs: False
|
||||
# hostname: "{{ vcsim }}"
|
||||
# username: root
|
||||
# password: esxi@123
|
||||
# datacenter_name: "{{ item | basename }}"
|
||||
# state: absent
|
||||
# switch_name: dvswitch_0001
|
||||
# mtu: 9000
|
||||
# uplink_quantity: 2
|
||||
# discovery_proto: lldp
|
||||
# discovery_operation: both
|
||||
# with_items:
|
||||
# - "{{ datacenters['json'] }}"
|
||||
# register: dvs_result_0003
|
||||
- name: delete the distributed vSwitch
|
||||
vmware_dvswitch:
|
||||
validate_certs: False
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
datacenter_name: "{{ dc1 }}"
|
||||
state: absent
|
||||
switch_name: dvswitch_0001
|
||||
register: dvs_result_0003
|
||||
|
||||
#- name: ensure distributed vswitch is present
|
||||
# assert:
|
||||
# that:
|
||||
# - "{{ dvs_result_0003.changed == true }}"
|
||||
|
||||
#- 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 }}"
|
||||
- name: ensure distributed vswitch is present
|
||||
assert:
|
||||
that:
|
||||
- dvs_result_0003.changed
|
||||
|
||||
Reference in New Issue
Block a user