From 2c58ac18335d9ccde20b181d76eafa8246a3add2 Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Thu, 4 May 2017 21:22:48 +0200 Subject: [PATCH] inventory: ovirt4: Add support for devices without IP (#24287) --- contrib/inventory/ovirt4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/inventory/ovirt4.py b/contrib/inventory/ovirt4.py index 5ee59862661..6221325f340 100755 --- a/contrib/inventory/ovirt4.py +++ b/contrib/inventory/ovirt4.py @@ -182,9 +182,9 @@ def get_dict_of_struct(connection, vm): (stat.name, stat.values[0].datum) for stat in stats ), 'devices': dict( - (device.name, [ip.address for ip in device.ips]) for device in devices + (device.name, [ip.address for ip in device.ips]) for device in devices if device.ips ), - 'ansible_host': devices[0].ips[0].address if len(devices) > 0 else None, + 'ansible_host': next((device.ips[0].address for device in devices if device.ips), None) }