| 1 |
# Test code for the module vmware_host_sriov |
| 2 |
|
| 3 |
- import_role: |
| 4 |
name: prepare_vmware_tests |
| 5 |
vars: |
| 6 |
setup_attach_host: true |
| 7 |
|
| 8 |
- name: Gather vmnic info |
| 9 |
community.vmware.vmware_host_vmnic_info: |
| 10 |
hostname: "{{ vcenter_hostname }}" |
| 11 |
username: "{{ vcenter_username }}" |
| 12 |
password: "{{ vcenter_password }}" |
| 13 |
esxi_hostname: "{{ esxi1 }}" |
| 14 |
validate_certs: false |
| 15 |
sriov: true |
| 16 |
register: host_vmnics |
| 17 |
|
| 18 |
- name: Extract vmnic0 info |
| 19 |
set_fact: |
| 20 |
vmnic0_info: "{{ item }}" |
| 21 |
loop: "{{ host_vmnics.hosts_vmnics_info[esxi1].vmnic_details }}" |
| 22 |
when: item.device == "vmnic0" |
| 23 |
|
| 24 |
- when: vmnic0_info.sriov_status == "Enabled" |
| 25 |
block: |
| 26 |
- name: enable SR-IOV on vmnic0 with 8 functions |
| 27 |
vmware_host_sriov: |
| 28 |
hostname: "{{ vcenter_hostname }}" |
| 29 |
username: "{{ vcenter_username }}" |
| 30 |
password: "{{ vcenter_password }}" |
| 31 |
esxi_hostname: "{{ esxi1 }}" |
| 32 |
validate_certs: false |
| 33 |
vmnic: vmnic0 |
| 34 |
sriov_on: true |
| 35 |
num_virt_func: 8 |
| 36 |
register: present |
| 37 |
- debug: var=present |
| 38 |
|
| 39 |
- name: enable SR-IOV on already enabled interface vmnic0 |
| 40 |
vmware_host_sriov: |
| 41 |
hostname: "{{ vcenter_hostname }}" |
| 42 |
username: "{{ vcenter_username }}" |
| 43 |
password: "{{ vcenter_password }}" |
| 44 |
esxi_hostname: "{{ esxi1 }}" |
| 45 |
validate_certs: false |
| 46 |
vmnic: vmnic0 |
| 47 |
sriov_on: true |
| 48 |
num_virt_func: 8 |
| 49 |
register: present |
| 50 |
- debug: var=present |
| 51 |
|
| 52 |
- name: enable SR-IOV on vmnic0 with big num. of functions |
| 53 |
vmware_host_sriov: |
| 54 |
hostname: "{{ vcenter_hostname }}" |
| 55 |
username: "{{ vcenter_username }}" |
| 56 |
password: "{{ vcenter_password }}" |
| 57 |
esxi_hostname: "{{ esxi1 }}" |
| 58 |
validate_certs: false |
| 59 |
vmnic: vmnic0 |
| 60 |
sriov_on: true |
| 61 |
num_virt_func: 100 |
| 62 |
ignore_errors: true |
| 63 |
register: present |
| 64 |
- debug: var=present |
| 65 |
|
| 66 |
- name: change num of functions only |
| 67 |
vmware_host_sriov: |
| 68 |
hostname: "{{ vcenter_hostname }}" |
| 69 |
username: "{{ vcenter_username }}" |
| 70 |
password: "{{ vcenter_password }}" |
| 71 |
esxi_hostname: "{{ esxi1 }}" |
| 72 |
validate_certs: false |
| 73 |
vmnic: vmnic0 |
| 74 |
sriov_on: true |
| 75 |
num_virt_func: 10 |
| 76 |
register: present |
| 77 |
- debug: var=present |
| 78 |
|
| 79 |
- name: disable SR-IOV on vmnic0 |
| 80 |
vmware_host_sriov: |
| 81 |
hostname: "{{ vcenter_hostname }}" |
| 82 |
username: "{{ vcenter_username }}" |
| 83 |
password: "{{ vcenter_password }}" |
| 84 |
esxi_hostname: "{{ esxi1 }}" |
| 85 |
validate_certs: false |
| 86 |
vmnic: vmnic0 |
| 87 |
sriov_on: false |
| 88 |
num_virt_func: 0 |
| 89 |
register: present |
| 90 |
- debug: var=present |
| 91 |
|
| 92 |
- name: change num of functions only, check mode |
| 93 |
vmware_host_sriov: |
| 94 |
hostname: "{{ vcenter_hostname }}" |
| 95 |
username: "{{ vcenter_username }}" |
| 96 |
password: "{{ vcenter_password }}" |
| 97 |
esxi_hostname: "{{ esxi1 }}" |
| 98 |
validate_certs: false |
| 99 |
vmnic: vmnic0 |
| 100 |
sriov_on: true |
| 101 |
num_virt_func: 10 |
| 102 |
check_mode: true |
| 103 |
register: present |
| 104 |
- debug: var=present |
| 105 |
|
| 106 |
- name: disable SR-IOV with num_virt_func == 1, check mode |
| 107 |
vmware_host_sriov: |
| 108 |
hostname: "{{ vcenter_hostname }}" |
| 109 |
username: "{{ vcenter_username }}" |
| 110 |
password: "{{ vcenter_password }}" |
| 111 |
esxi_hostname: "{{ esxi1 }}" |
| 112 |
validate_certs: false |
| 113 |
vmnic: vmnic0 |
| 114 |
sriov_on: false |
| 115 |
num_virt_func: 1 |
| 116 |
check_mode: true |
| 117 |
register: present |
| 118 |
- debug: var=present |