bin/pvl.dns-hosts
changeset 264 ce29be46f705
parent 263 5ee3bcd5b4b5
child 265 5f2807999222
--- a/bin/pvl.dns-hosts	Mon Dec 16 15:24:57 2013 +0200
+++ b/bin/pvl.dns-hosts	Mon Dec 16 16:51:38 2013 +0200
@@ -132,18 +132,22 @@
             log.warn("host %s: ignore unknown item: %s", host, item)
 
     # determine hostname
-    if hostname :
-        pass
-    elif fixed_address and not re.match(r'\d+\.\d+\.\d+.\d+', fixed_address) :
-        hostname, domain = fixed_address.split('.', 1)
-    elif '-' in host :
+    suffix = None
+
+    if '-' in host :
         hostname, suffix = host.rsplit('-', 1)
     else :
-        log.warn("%s: guess hostname: %s", host, host)
         hostname = host
 
-    if hostname :
+    if fixed_address and not re.match(r'\d+\.\d+\.\d+.\d+', fixed_address) :
+        hostname, domain = fixed_address.split('.', 1)
+
+    #if suffix :
+    #    yield hostname, 'ethernet:{suffix}'.format(suffix=suffix), ethernet
+    if hostname and ethernet :
         yield hostname, 'ethernet', ethernet
+    else :
+        log.warn("%s: no hostname/ethernet: %s/%s", host, hostname, ethernet)
 
 def import_dhcp_hosts (options, blocks) :
     """
@@ -269,7 +273,7 @@
     """
 
     if info.get('owner').lower() in NONE_OWNERS :
-        return
+        return False
     
     # from ldap?
     for ldap in process_host_owner_ldap(options, host, info) :
@@ -295,15 +299,24 @@
     
     owner = process_host_owner(options, host, info) 
 
-    if owner :
+    if owner is False :
+        # do not mark any owner
+        pass
+
+    elif owner :
         owner, comment = owner
         
         log.info("%s: %s (%s)", host, owner, comment)
         
         yield 'owner-comment', comment
         yield 'owner', owner,
+
     else :
-        log.warn("%s: no owner: %s", host, info)
+        log.warn("%s: unknown owner: %s", host, info)
+        yield 'comment', "owner: {group} / {owner}".format(
+                group   = info.get('group', ''),
+                owner   = info.get('owner', ''),
+        )
     
     if info.get('host') :
         yield 'comment', info['host']