mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: add check for empty inventory
This commit is contained in:
parent
bfa71054f5
commit
9e5a16703b
1 changed files with 4 additions and 0 deletions
|
@ -129,6 +129,8 @@ class CloudStackInventory(object):
|
||||||
def get_host(self, name, project_id=''):
|
def get_host(self, name, project_id=''):
|
||||||
hosts = self.cs.listVirtualMachines(projectid=project_id)
|
hosts = self.cs.listVirtualMachines(projectid=project_id)
|
||||||
data = {}
|
data = {}
|
||||||
|
if not hosts:
|
||||||
|
return data
|
||||||
for host in hosts['virtualmachine']:
|
for host in hosts['virtualmachine']:
|
||||||
host_name = host['displayname']
|
host_name = host['displayname']
|
||||||
if name == host_name:
|
if name == host_name:
|
||||||
|
@ -182,6 +184,8 @@ class CloudStackInventory(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
hosts = self.cs.listVirtualMachines(projectid=project_id)
|
hosts = self.cs.listVirtualMachines(projectid=project_id)
|
||||||
|
if not hosts:
|
||||||
|
return data
|
||||||
for host in hosts['virtualmachine']:
|
for host in hosts['virtualmachine']:
|
||||||
host_name = host['displayname']
|
host_name = host['displayname']
|
||||||
data['all']['hosts'].append(host_name)
|
data['all']['hosts'].append(host_name)
|
||||||
|
|
Loading…
Reference in a new issue