mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
VMware: Add managed object id in VM facts (#53523)
Fixes: #53372 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
ae373d5a10
commit
2007a79952
4 changed files with 34 additions and 2 deletions
|
@ -302,6 +302,8 @@ def gather_vm_facts(content, vm):
|
|||
'snapshots': [],
|
||||
'current_snapshot': None,
|
||||
'vnc': {},
|
||||
'moid': vm._moId,
|
||||
'vimref': "vim.VirtualMachine:%s" % vm._moId,
|
||||
}
|
||||
|
||||
# facts that may or may not exist
|
||||
|
@ -1378,6 +1380,13 @@ class PyVmomi(object):
|
|||
self._deepmerge(result, tmp)
|
||||
else:
|
||||
result[prop] = self._jsonify(getattr(obj, prop))
|
||||
# To match gather_vm_facts output
|
||||
prop_name = prop
|
||||
if prop.lower() == '_moid':
|
||||
prop_name = 'moid'
|
||||
elif prop.lower() == '_vimref':
|
||||
prop_name = 'vimref'
|
||||
result[prop_name] = result[prop]
|
||||
except (AttributeError, KeyError):
|
||||
self.module.fail_json(msg="Property '{0}' not found.".format(prop))
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue