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:
parent
c22ec81b99
commit
df507ca9c4
2 changed files with 7 additions and 7 deletions
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue