mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
vmware: refactoring of vmware test roles -- part7 (#55732)
Refactoring of the following roles to make use of the new `prepare_vmware_tests` role. - `vmware_resource_pool` - `vmware_resource_pool_facts` - `vmware_target_canonical_facts` - `vmware_vcenter_settings` - `vmware_vcenter_statistics` - `vmware_vm_facts` - `vmware_vm_host_drs_rule` - `vmware_vm_vm_drs_rule` - `vmware_vmkernel` - `vmware_vmkernel_facts` - `vmware_vspan_session` - `vmware_vswitch` - `vmware_vswitch_facts` 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:
committed by
ansibot
parent
2ef8b297ff
commit
affaedfca8
@@ -1,2 +1,3 @@
|
||||
cloud/vcenter
|
||||
unsupported
|
||||
shippable/vcenter/group1
|
||||
needs/target/prepare_vmware_tests
|
||||
|
||||
@@ -2,42 +2,19 @@
|
||||
# Copyright: (c) 2018, Peter Gyorgy <gyorgy.peter@edu.bme.hu>
|
||||
# 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
|
||||
- import_role:
|
||||
name: prepare_vmware_tests
|
||||
vars:
|
||||
setup_attach_host: true
|
||||
|
||||
- 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
|
||||
|
||||
- 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
|
||||
@@ -45,35 +22,17 @@
|
||||
discovery_proto: lldp
|
||||
discovery_operation: both
|
||||
register: dvs_result_0001
|
||||
with_items:
|
||||
- "{{ datacenters['json'] }}"
|
||||
|
||||
- debug: var=dvs_result_0001
|
||||
- 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 }}"
|
||||
|
||||
- name: Create vlan portgroup with all security and port policies
|
||||
vmware_dvs_portgroup:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: False
|
||||
portgroup_name: vlan-123-portrgoup
|
||||
switch_name: dvswitch_0001
|
||||
@@ -104,39 +63,40 @@
|
||||
that:
|
||||
- portgroup_create_result.changed
|
||||
|
||||
- name: create a session.
|
||||
vmware_vspan_session:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
validate_certs: False
|
||||
switch: dvswitch_0001
|
||||
name: "session_0001"
|
||||
state: "present"
|
||||
enabled: True
|
||||
description: "basic_description"
|
||||
source_port_transmitted: 13
|
||||
source_port_received: 13
|
||||
destination_port: 12
|
||||
register: vspan_session_create_result
|
||||
- when: vcsim is not defined
|
||||
block:
|
||||
- name: create a session.
|
||||
vmware_vspan_session:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: False
|
||||
switch: dvswitch_0001
|
||||
name: "session_0001"
|
||||
state: "present"
|
||||
enabled: True
|
||||
description: "basic_description"
|
||||
source_port_transmitted: 13
|
||||
source_port_received: 13
|
||||
destination_port: 12
|
||||
register: vspan_session_create_result
|
||||
- debug: var=vspan_session_create_result
|
||||
- name: ensure session was created
|
||||
assert:
|
||||
that:
|
||||
- vspan_session_create_result.changed
|
||||
|
||||
- name: ensure session was created
|
||||
assert:
|
||||
that:
|
||||
- vspan_session_create_result.changed
|
||||
|
||||
- name: delete a session.
|
||||
vmware_vspan_session:
|
||||
hostname: "{{ vcsim }}"
|
||||
username: "{{ vcsim_instance['json']['username'] }}"
|
||||
password: "{{ vcsim_instance['json']['password'] }}"
|
||||
validate_certs: False
|
||||
switch: dvswitch_0001
|
||||
name: "session_0001"
|
||||
state: "absent"
|
||||
register: vspan_session_delete_result
|
||||
|
||||
- name: ensure session was deleted
|
||||
assert:
|
||||
that:
|
||||
- vspan_session_delete_result.changed
|
||||
- name: delete a session.
|
||||
vmware_vspan_session:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: False
|
||||
switch: dvswitch_0001
|
||||
name: "session_0001"
|
||||
state: "absent"
|
||||
register: vspan_session_delete_result
|
||||
- name: ensure session was deleted
|
||||
assert:
|
||||
that:
|
||||
- vspan_session_delete_result.changed
|
||||
|
||||
Reference in New Issue
Block a user