Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMware: Parse VM object for YAML parser #52557

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/ansible/plugins/inventory/vmware_vm_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,16 @@ def _populate_from_source(self, source_data, using_current_cache):
'customValue',
]
for vm_prop in vm_properties:
vm_value = self._get_vm_prop(temp_vm_object.obj, vm_prop.split("."))
self.inventory.set_variable(current_host, vm_prop, vm_value)
if vm_prop == 'customValue':
field_mgr = self.content.customFieldsManager.field
for cust_value in temp_vm_object.obj.customValue:
self.inventory.set_variable(current_host,
[y.name for y in field_mgr if y.key == cust_value.key][0],
cust_value.value)
else:
vm_value = self._get_vm_prop(temp_vm_object.obj, vm_prop.split("."))
self.inventory.set_variable(current_host, vm_prop, vm_value)

# Only gather facts related to tag if vCloud and vSphere is installed.
if HAS_VCLOUD and HAS_VSPHERE and self.with_tags:
# Add virtual machine to appropriate tag group
Expand All @@ -387,7 +395,7 @@ def _populate_from_source(self, source_data, using_current_cache):
cacheable_results[tags_info[tag_id]]['hosts'].append(current_host)

# Based on power state of virtual machine
vm_power = temp_vm_object.obj.summary.runtime.powerState
vm_power = str(temp_vm_object.obj.summary.runtime.powerState)
if vm_power not in cacheable_results:
cacheable_results[vm_power] = []
self.inventory.add_group(vm_power)
Expand Down