mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
cloudstack: use paging for listVirtualMachines (#40018)
Paging wasn't implemented, so once a cs domain has over 500 (default page size) VMs, Ansible can no longer find newly created VM.
This commit is contained in:
@@ -147,11 +147,11 @@ class CloudStackInventory(object):
|
||||
sys.exit(1)
|
||||
|
||||
def get_host(self, name, project_id=None, domain_id=None, **kwargs):
|
||||
hosts = self.cs.listVirtualMachines(projectid=project_id, domainid=domain_id, **kwargs)
|
||||
hosts = self.cs.listVirtualMachines(projectid=project_id, domainid=domain_id, fetch_list=True, **kwargs)
|
||||
data = {}
|
||||
if not hosts:
|
||||
return data
|
||||
for host in hosts['virtualmachine']:
|
||||
for host in hosts:
|
||||
host_name = host['displayname']
|
||||
if name == host_name:
|
||||
data['zone'] = host['zonename']
|
||||
@@ -202,10 +202,10 @@ class CloudStackInventory(object):
|
||||
'hosts': []
|
||||
}
|
||||
|
||||
hosts = self.cs.listVirtualMachines(projectid=project_id, domainid=domain_id, **kwargs)
|
||||
hosts = self.cs.listVirtualMachines(projectid=project_id, domainid=domain_id, fetch_list=True, **kwargs)
|
||||
if not hosts:
|
||||
return data
|
||||
for host in hosts['virtualmachine']:
|
||||
for host in hosts:
|
||||
host_name = host['displayname']
|
||||
data['all']['hosts'].append(host_name)
|
||||
data['_meta']['hostvars'][host_name] = {}
|
||||
|
||||
Reference in New Issue
Block a user