From 3b17efe5bc9a6cbbc17ac06216ae1680121f6b76 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Fri, 28 Aug 2015 13:56:00 -0600 Subject: [PATCH] Fix setting dns_name in cobbler inventory --- contrib/inventory/cobbler.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/inventory/cobbler.py b/contrib/inventory/cobbler.py index 245d579a1cc..aca045eaf78 100755 --- a/contrib/inventory/cobbler.py +++ b/contrib/inventory/cobbler.py @@ -169,8 +169,15 @@ class CobblerInventory(object): dns_name = host['hostname'] #None ksmeta = None interfaces = host['interfaces'] - - if dns_name is None: + # hostname is often empty for non-static IP hosts + if dns_name == '': + for (iname, ivalue) in interfaces.iteritems(): + if ivalue['management'] or not ivalue['static']: + this_dns_name = ivalue.get('dns_name', None) + if this_dns_name is not None and this_dns_name is not "": + dns_name = this_dns_name + + if dns_name == '': continue status = host['status']