vmware: Add portgroup_portkey and portgroup_key (#38958)

* VMware: apply correct value for datacenter in TC

Signed-off-by: Tim Steinbach <tim@nequissimus.com>
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Tim Steinbach
2018-04-23 04:34:35 -04:00
committed by Abhijeet Kasurde
parent 7437d6fdc4
commit f61172e6c7
4 changed files with 114 additions and 4 deletions

View File

@@ -27,8 +27,10 @@
- include: delete_vm.yml
- include: non_existent_vm_ops.yml
- include: network_negative_test.yml
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
#- include: network_with_portgroup.yml
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
#- include: network_with_dvpg.yml
# - include: network_with_dvpg.yml
#- include: template_d1_c1_f0.yml
- include: vapp_d1_c1_f0.yml
- include: disk_size_d1_c1_f0.yml

View File

@@ -0,0 +1,96 @@
# Test code for the vmware_guest module.
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>, Tim Steinbach <tim@nequissimus.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 with no folders
uri:
url: http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0
register: vcsim_instance
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get a list of VMS from vcsim
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=VM
register: vmlist
- debug: var=vcsim_instance
- debug: var=vmlist
- set_fact:
vm1: "{{ vmlist['json'][0] }}"
- debug: var=vm1
- name: Create dvswitch
vmware_dvswitch:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
datacenter_name: "{{ (vm1 | basename).split('_')[0] }}"
switch_name: dvSwitch
uplink_quantity: 2
discovery_proto: lldp
discovery_operation: both
mtu: 9000
state: present
register: dvswitch
- name: Add portgroup
vmware_dvs_portgroup:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
portgroup_name: "portgroup_network"
switch_name: "{{ dvswitch.switch_name }}"
vlan_id: "1"
num_ports: 2
portgroup_type: earlyBinding
state: present
register: dvsportgroup
- name: create new VMs with portgroup
vmware_guest:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
name: new_vm_pg
guest_id: centos64Guest
datacenter: "{{ (vm1 | basename).split('_')[0] }}"
disk:
- size: 3mb
type: thin
autoselect_datastore: yes
networks:
- name: "{{ dvsportgroup.portgroup_name }}"
hardware:
num_cpus: 1
memory_mb: 512
state: poweredoff
folder: "{{ vm1 | dirname }}"
register: vm_with_portgroup
ignore_errors: no
- debug: var=vm_with_portgroup
- assert:
that:
- "vm_with_portgroup.changed"

View File

@@ -83,6 +83,8 @@
- "guest_facts_0001['instance']['hw_folder'] is defined"
- "guest_facts_0001['instance']['guest_question'] is defined"
- "guest_facts_0001['instance']['guest_consolidation_needed'] is defined"
- "'portgroup_portkey' in guest_facts_0001['instance']['hw_eth0']"
- "'portgroup_key' in guest_facts_0001['instance']['hw_eth0']"
- set_fact: vm1_uuid="{{ guest_facts_0001['instance']['hw_product_uuid'] }}"