vmware_datastore_facts: handle external datastore
Without this commit, `vmware_datastore_facts` ignores the datastores are not associated with a cluster of a datastore. This case can happen if a NFS share is mounted directly on a ESXi instance.
This commit is contained in:
parent
470371d009
commit
b8c170a322
1 changed files with 5 additions and 6 deletions
|
@ -233,9 +233,9 @@ class PyVmomiHelper(PyVmomi):
|
||||||
super(PyVmomiHelper, self).__init__(module)
|
super(PyVmomiHelper, self).__init__(module)
|
||||||
self.cache = PyVmomiCache(self.content, dc_name=self.params['datacenter'])
|
self.cache = PyVmomiCache(self.content, dc_name=self.params['datacenter'])
|
||||||
|
|
||||||
def lookup_datastore(self):
|
def lookup_datastore(self, confine_to_datacenter):
|
||||||
""" Get datastore(s) per ESXi host or vCenter server """
|
""" Get datastore(s) per ESXi host or vCenter server """
|
||||||
datastores = self.cache.get_all_objs(self.content, [vim.Datastore], confine_to_datacenter=True)
|
datastores = self.cache.get_all_objs(self.content, [vim.Datastore], confine_to_datacenter)
|
||||||
return datastores
|
return datastores
|
||||||
|
|
||||||
def lookup_datastore_by_cluster(self):
|
def lookup_datastore_by_cluster(self):
|
||||||
|
@ -258,9 +258,6 @@ def main():
|
||||||
gather_vmfs_mount_info=dict(type='bool', default=False)
|
gather_vmfs_mount_info=dict(type='bool', default=False)
|
||||||
)
|
)
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
required_one_of=[
|
|
||||||
['cluster', 'datacenter'],
|
|
||||||
],
|
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
result = dict(changed=False)
|
result = dict(changed=False)
|
||||||
|
@ -269,8 +266,10 @@ def main():
|
||||||
|
|
||||||
if module.params['cluster']:
|
if module.params['cluster']:
|
||||||
dxs = pyv.lookup_datastore_by_cluster()
|
dxs = pyv.lookup_datastore_by_cluster()
|
||||||
|
elif module.params['datacenter']:
|
||||||
|
dxs = pyv.lookup_datastore(confine_to_datacenter=True)
|
||||||
else:
|
else:
|
||||||
dxs = pyv.lookup_datastore()
|
dxs = pyv.lookup_datastore(confine_to_datacenter=False)
|
||||||
|
|
||||||
vmware_host_datastore = VMwareHostDatastore(module)
|
vmware_host_datastore = VMwareHostDatastore(module)
|
||||||
datastores = vmware_host_datastore.build_datastore_list(dxs)
|
datastores = vmware_host_datastore.build_datastore_list(dxs)
|
||||||
|
|
Loading…
Reference in a new issue