Implement second change from #30826

pull/27756/merge
James Tanner 7 years ago committed by jctanner
parent 1c1c89927d
commit 8c368b25cd

@ -447,10 +447,13 @@ class PyVmomiCache(object):
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
# make a copy
tmpobjs = objects.copy()
for k, v in objects.items(): for k, v in objects.items():
parent_dc = self.get_parent_datacenter(k) parent_dc = self.get_parent_datacenter(k)
if parent_dc.name != self.dc_name: if parent_dc.name != self.dc_name:
objects.pop(k, None) tmpobjs.pop(k, None)
objects = tmpobjs
else: else:
# everything else should be a list # everything else should be a list
objects = [x for x in objects if self.get_parent_datacenter(x).name == self.dc_name] objects = [x for x in objects if self.get_parent_datacenter(x).name == self.dc_name]

Loading…
Cancel
Save