1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

vmware_guest: fixes for cache objects and datacenter association (#26719)

* vmware_guest: fixes for cache objects and datacenter association
* find_all_objs was only looking for datastores
* Clear the result if it's datacenter is not correct.
* Re-enable pyvmomi installation

Addresses #25011
Addresses #26511
This commit is contained in:
jctanner 2017-07-12 17:10:48 -04:00 committed by GitHub
parent c22ec81b99
commit df507ca9c4
2 changed files with 7 additions and 7 deletions

View file

@ -449,16 +449,16 @@ class PyVmomiCache(object):
result = find_obj(content, types, name) result = find_obj(content, types, name)
if result and confine_to_datacenter: if result and confine_to_datacenter:
if self.get_parent_datacenter(result).name != self.dc_name: if self.get_parent_datacenter(result).name != self.dc_name:
result = None
objects = self.get_all_objs(content, types, confine_to_datacenter=True) objects = self.get_all_objs(content, types, confine_to_datacenter=True)
for obj in objects: for obj in objects:
if obj.name == name: if name is None or obj.name == name:
return obj return obj
return result return result
def get_all_objs(self, content, types, confine_to_datacenter=True): def get_all_objs(self, content, types, confine_to_datacenter=True):
""" Wrapper around get_all_objs to set datacenter context """ """ Wrapper around get_all_objs to set datacenter context """
objects = get_all_objs(content, [vim.Datastore]) objects = get_all_objs(content, types)
if confine_to_datacenter: if confine_to_datacenter:
if hasattr(objects, 'items'): if hasattr(objects, 'items'):
# resource pools come back as a dictionary # resource pools come back as a dictionary

View file

@ -1,7 +1,7 @@
#- name: make sure pyvmomi is installed - name: make sure pyvmomi is installed
# pip: pip:
# name: pyvmomi name: pyvmomi
# state: latest state: latest
- name: store the vcenter container ip - name: store the vcenter container ip
set_fact: set_fact: