vApp properties support (#32579)

* Adding support for vApp properties.
* vm specification updated only if changes have to be applied. I.e. subsequent updates with the same data will not trigger changed state
* Auxiliary variables renamed, hope this makes the code more readable
* Integration tests changed - re-adding the same properties test not implemented, but tested on real vCenter deployment
* fixing documentation "version_added" for the feature
* Addressing reviewers comments #2:
* documentation updated with the only meaningful value for "option" attribute - "remove"
* Fixed improperly handled case when user requested "add" operation for existent property
* vApp configuration is updated only with properties that contains changes, not with all properties requested by user
This commit is contained in:
goshkis 2018-02-20 22:29:13 -08:00 committed by Abhijeet Kasurde
commit abb956d9eb
3 changed files with 216 additions and 0 deletions

View file

@ -31,3 +31,4 @@
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
#- include: network_with_dvpg.yml
#- include: template_d1_c1_f0.yml
- include: vapp_d1_c1_f0.yml

View file

@ -0,0 +1,107 @@
- 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 Clusters from vcsim
uri:
url: "{{ 'http://' + vcsim + ':5000/govc_find?filter=CCR' }}"
register: clusterlist
- debug: var=vcsim_instance
- debug: var=clusterlist
- name: Create test VM
vmware_guest:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm"
name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}"
cluster: "{{ clusterlist['json'][0] }}"
resource_pool: Resources
guest_id: centos64Guest
hardware:
memory_mb: 512
num_cpus: 1
scsi: paravirtual
disk:
- size_mb: 128
type: thin
datastore: LocalDS_0
register: vapp_vm
- debug: var=vapp_vm
- name: Define vApp properties for the new VM
vmware_guest:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm"
name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}"
vapp_properties:
- id: prop_id1
category: category
label: prop_label1
type: string
value: prop_value1
- id: prop_id2
category: category
label: prop_label2
type: string
value: prop_value2
state: present
register: vapp_vm
- debug: var=vapp_vm
- name: assert the vApp propeties were created
assert:
that:
- "vapp_vm.failed == false"
- "vapp_vm.changed == true"
- name: Edit one vApp property and removing another
vmware_guest:
validate_certs: False
hostname: "{{ vcsim }}"
username: "{{ vcsim_instance['json']['username'] }}"
password: "{{ vcsim_instance['json']['password'] }}"
folder: "/{{ (clusterlist['json'][0]|basename).split('_')[0] }}/vm"
name: vApp-Test
datacenter: "{{ (clusterlist['json'][0]|basename).split('_')[0] }}"
vapp_properties:
- id: prop_id1
operation: remove
- id: prop_id2
value: prop_value3
state: present
register: vapp_vm
- debug: var=vapp_vm
- name: assert the VM was changed
assert:
that:
- "vapp_vm.failed == false"
- "vapp_vm.changed == true"