vmware_guest: Various fixes to VM customizations (from template) (#24768)

* Various fixes to VM customizations (from template)

This patch implements:
- New find_obj() function from vmware.py replacing get_obj()
- Implement proper resource_pool selection
- Fix productId implementation (was not working)
- Ensure that we are not changing anything that is not mandatory (hostName, orgName, fullName)


This is an alternative proposal to #24283
This does not fix #19860 yet though.

For our use-case, we do not want to customize the network information (or any information in fact).
What is used in the template should remain intact.

* Added find_obj() function

* Fix the returned object-list (unused yet)

* Small improvement

* Support DHCP type and fix customizations

* Small fix

* Support resource_pool also for reconfiguring VM

* Remove redundant

* Fix short hostname, specific resource_pool, PEP8

* Improve docs and examples

* Fix missing hostsystem

* Make folder absolute path

* Improve docs, add missing 'mac'
pull/24666/head
Dag Wieers 8 years ago committed by jctanner
parent bd4f08d434
commit cf30b162a9

@ -52,6 +52,30 @@ def wait_for_task(task):
time.sleep(15)
def find_obj(content, vimtype, name, first=True):
container = content.viewManager.CreateContainerView(container=content.rootFolder, recursive=True, type=vimtype)
obj_list = container.view
container.Destroy()
# Backward compatible with former get_obj() function
if name is None:
if obj_list:
return obj_list[0]
return None
# Select the first match
if first is True:
for obj in obj_list:
if obj.name == name:
return obj
# If no object found, return None
return None
# Return all matching objects if needed
return [obj for obj in obj_list if obj.name == name]
def find_dvspg_by_name(dv_switch, portgroup_name):
portgroups = dv_switch.portgroup

File diff suppressed because it is too large Load Diff

@ -196,7 +196,6 @@ lib/ansible/modules/cloud/vmware/vca_nat.py
lib/ansible/modules/cloud/vmware/vca_vapp.py
lib/ansible/modules/cloud/vmware/vmware_cluster.py
lib/ansible/modules/cloud/vmware/vmware_dvswitch.py
lib/ansible/modules/cloud/vmware/vmware_guest.py
lib/ansible/modules/cloud/vmware/vmware_local_user_manager.py
lib/ansible/modules/cloud/vmware/vmware_migrate_vmk.py
lib/ansible/modules/cloud/vmware/vmware_target_canonical_facts.py

Loading…
Cancel
Save