vmware_datastore_facts: don't modify dict in iter
With Python3, we cannot iterate on a dict and modify it at the same time.
Fixes #54869
(cherry picked from commit 339a0f4a8c
)
This commit is contained in:
parent
d112106985
commit
51a849c89f
2 changed files with 5 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- With Python3, we cannot iterate on a dict and modify it at the same time (https://github.com/ansible/ansible/issues/54869).
|
|
@ -214,10 +214,12 @@ class PyVmomiCache(object):
|
|||
if confine_to_datacenter:
|
||||
if hasattr(objects, 'items'):
|
||||
# resource pools come back as a dictionary
|
||||
tmpobjs = objects.copy()
|
||||
for k, v in objects.items():
|
||||
parent_dc = get_parent_datacenter(k)
|
||||
if parent_dc.name != self.dc_name:
|
||||
objects.pop(k, None)
|
||||
tmpobjs.pop(k, None)
|
||||
objects = tmpobjs
|
||||
else:
|
||||
# everything else should be a list
|
||||
objects = [x for x in objects if get_parent_datacenter(x).name == self.dc_name]
|
||||
|
|
Loading…
Reference in a new issue