From bfa71054f55865297a03ec9d66ce89e57b2824d8 Mon Sep 17 00:00:00 2001 From: Milamber Date: Sat, 3 Jan 2015 18:57:55 +0000 Subject: [PATCH] Fix an issue when the cloudstack installation don't have any instance group --- plugins/inventory/cloudstack.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/inventory/cloudstack.py b/plugins/inventory/cloudstack.py index fdd166ec49..4969b613fe 100755 --- a/plugins/inventory/cloudstack.py +++ b/plugins/inventory/cloudstack.py @@ -173,12 +173,13 @@ class CloudStackInventory(object): } groups = self.cs.listInstanceGroups(projectid=project_id) - for group in groups['instancegroup']: - group_name = group['name'] - if group_name and not group_name in data: - data[group_name] = { - 'hosts': [] - } + if groups: + for group in groups['instancegroup']: + group_name = group['name'] + if group_name and not group_name in data: + data[group_name] = { + 'hosts': [] + } hosts = self.cs.listVirtualMachines(projectid=project_id) for host in hosts['virtualmachine']: