|
|
|
@ -71,8 +71,10 @@
|
|
|
|
|
state: new
|
|
|
|
|
device_type: e1000e
|
|
|
|
|
manual_mac: "aa:50:56:58:59:60"
|
|
|
|
|
connected: True
|
|
|
|
|
- name: "VM Network"
|
|
|
|
|
state: new
|
|
|
|
|
connected: True
|
|
|
|
|
device_type: vmxnet3
|
|
|
|
|
manual_mac: "aa:50:56:58:59:61"
|
|
|
|
|
register: add_netadapter
|
|
|
|
@ -82,7 +84,7 @@
|
|
|
|
|
- name: assert the new netowrk adapters were added to VM
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "add_netadapter.changed == true"
|
|
|
|
|
- add_netadapter is changed
|
|
|
|
|
- "{{ add_netadapter.network_data | length | int }} == {{ netadapter_num | int + 2 }}"
|
|
|
|
|
|
|
|
|
|
- name: delete one specified network adapter
|
|
|
|
@ -102,9 +104,65 @@
|
|
|
|
|
- name: assert the network adapter was removed
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "del_netadapter.changed == true"
|
|
|
|
|
- del_netadapter is changed
|
|
|
|
|
- "{{ del_netadapter.network_data | length | int }} == {{ netadapter_num | int + 1 }}"
|
|
|
|
|
|
|
|
|
|
- name: get instance uuid of virtual machines
|
|
|
|
|
vmware_guest_info:
|
|
|
|
|
validate_certs: False
|
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
|
name: "{{ virtual_machines[0].name }}"
|
|
|
|
|
datacenter: '{{ dc1 }}'
|
|
|
|
|
register: guest_info
|
|
|
|
|
|
|
|
|
|
- set_fact: vm1_instance_uuid="{{ guest_info['instance']['instance_uuid'] }}"
|
|
|
|
|
|
|
|
|
|
- name: add new network adapters to virtual machine with instance uuid
|
|
|
|
|
vmware_guest_network:
|
|
|
|
|
validate_certs: False
|
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
|
uuid: "{{ vm1_instance_uuid }}"
|
|
|
|
|
use_instance_uuid: True
|
|
|
|
|
networks:
|
|
|
|
|
- name: "VM Network"
|
|
|
|
|
state: new
|
|
|
|
|
connected: True
|
|
|
|
|
device_type: e1000e
|
|
|
|
|
manual_mac: "00:50:56:58:59:60"
|
|
|
|
|
register: add_netadapter_instanceuuid
|
|
|
|
|
|
|
|
|
|
- debug: var=add_netadapter_instanceuuid
|
|
|
|
|
|
|
|
|
|
- name: assert the new netowrk adapters were added to VM
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- add_netadapter_instanceuuid is changed
|
|
|
|
|
- "{{ add_netadapter_instanceuuid.network_data | length | int }} == {{ netadapter_num | int + 2 }}"
|
|
|
|
|
|
|
|
|
|
- name: delete again one specified network adapter
|
|
|
|
|
vmware_guest_network:
|
|
|
|
|
validate_certs: False
|
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
|
name: "{{ virtual_machines[0].name }}"
|
|
|
|
|
networks:
|
|
|
|
|
- state: absent
|
|
|
|
|
mac: "00:50:56:58:59:60"
|
|
|
|
|
register: del_again_netadapter
|
|
|
|
|
|
|
|
|
|
- debug: var=del_again_netadapter
|
|
|
|
|
|
|
|
|
|
- name: assert the network adapter was removed
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- del_again_netadapter is changed
|
|
|
|
|
- "{{ del_again_netadapter.network_data | length | int }} == {{ netadapter_num | int + 1 }}"
|
|
|
|
|
|
|
|
|
|
- name: disconnect one specified network adapter
|
|
|
|
|
vmware_guest_network:
|
|
|
|
|
validate_certs: False
|
|
|
|
@ -123,7 +181,7 @@
|
|
|
|
|
- name: assert the network adapter was disconnected
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "disc_netadapter.changed == true"
|
|
|
|
|
- disc_netadapter is changed
|
|
|
|
|
- "{{ disc_netadapter.network_data[netadapter_num]['connected'] }} == false"
|
|
|
|
|
|
|
|
|
|
- name: Check if network does not exists
|
|
|
|
@ -145,5 +203,5 @@
|
|
|
|
|
- name: Check if network does not exists
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- not no_nw_details.changed
|
|
|
|
|
- not (no_nw_details is changed)
|
|
|
|
|
- no_nw_details.failed
|
|
|
|
|