mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
vmware_vm_facts: fix the support with regular ESXi
Ensure the module still work with the ESXi where CustomFieldsManager does not exist. From: https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.CustomFieldsManager.html The CustomFieldsManager object is used to add and remove custom fields to managed entities. The custom fields values set on managed entities are available through the customValue property and through the summary objects for VirtualMachine and HostSystem. They are not available directly through this managed object. This functionality is only available through VirtualCenter. Fixes: #56071
This commit is contained in:
@@ -91,7 +91,6 @@ except ImportError:
|
||||
class VmAttributeDefManager(PyVmomi):
|
||||
def __init__(self, module):
|
||||
super(VmAttributeDefManager, self).__init__(module)
|
||||
self.custom_field_mgr = self.content.customFieldsManager.field
|
||||
|
||||
def remove_custom_def(self, field):
|
||||
changed = False
|
||||
|
||||
@@ -139,7 +139,6 @@ from ansible.module_utils.vmware import PyVmomi, vmware_argument_spec
|
||||
class VmAttributeManager(PyVmomi):
|
||||
def __init__(self, module):
|
||||
super(VmAttributeManager, self).__init__(module)
|
||||
self.custom_field_mgr = self.content.customFieldsManager.field
|
||||
|
||||
def set_custom_field(self, vm, user_fields):
|
||||
result_fields = dict()
|
||||
|
||||
@@ -18,9 +18,9 @@ ANSIBLE_METADATA = {
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: vmware_vm_facts
|
||||
short_description: Return basic facts pertaining to a vSphere virtual machine guest
|
||||
short_description: Return basic facts pertaining to a VMware machine guest
|
||||
description:
|
||||
- Return basic facts pertaining to a vSphere virtual machine guest.
|
||||
- Return basic facts pertaining to a vSphere or ESXi virtual machine guest.
|
||||
- Cluster name as fact is added in version 2.7.
|
||||
version_added: '2.0'
|
||||
author:
|
||||
@@ -28,7 +28,7 @@ author:
|
||||
- Abhijeet Kasurde (@Akasurde)
|
||||
- Fedor Vompe (@sumkincpp)
|
||||
notes:
|
||||
- Tested on vSphere 5.5 and vSphere 6.5
|
||||
- Tested on ESXi 6.7, vSphere 5.5 and vSphere 6.5
|
||||
- From 2.8 and onwards, facts are returned as list of dict instead of dict.
|
||||
requirements:
|
||||
- python >= 2.6
|
||||
@@ -165,7 +165,6 @@ from ansible.module_utils.vmware import PyVmomi, get_all_objs, vmware_argument_s
|
||||
class VmwareVmFacts(PyVmomi):
|
||||
def __init__(self, module):
|
||||
super(VmwareVmFacts, self).__init__(module)
|
||||
self.custom_field_mgr = self.content.customFieldsManager.field
|
||||
|
||||
def get_vm_attributes(self, vm):
|
||||
return dict((x.name, v.value) for x in self.custom_field_mgr
|
||||
|
||||
Reference in New Issue
Block a user