From 9e5a16703b81953f9ee0334ee52413533480f460 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 10 Feb 2015 09:50:41 +0100 Subject: [PATCH] cloudstack: add check for empty inventory --- plugins/inventory/cloudstack.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/inventory/cloudstack.py b/plugins/inventory/cloudstack.py index 4969b613fe..d0b2f042d3 100755 --- a/plugins/inventory/cloudstack.py +++ b/plugins/inventory/cloudstack.py @@ -129,6 +129,8 @@ class CloudStackInventory(object): def get_host(self, name, project_id=''): hosts = self.cs.listVirtualMachines(projectid=project_id) data = {} + if not hosts: + return data for host in hosts['virtualmachine']: host_name = host['displayname'] if name == host_name: @@ -182,6 +184,8 @@ class CloudStackInventory(object): } hosts = self.cs.listVirtualMachines(projectid=project_id) + if not hosts: + return data for host in hosts['virtualmachine']: host_name = host['displayname'] data['all']['hosts'].append(host_name)