mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07: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:
parent
06f76d6407
commit
16994bbdca
5 changed files with 12 additions and 8 deletions
|
@ -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] = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue