pvl/hosts/zone.py
changeset 687 f99f9e3d02cf
parent 686 6416c448a713
child 733 45bedeba92e5
--- a/pvl/hosts/zone.py	Mon Mar 02 13:12:35 2015 +0200
+++ b/pvl/hosts/zone.py	Mon Mar 02 13:26:34 2015 +0200
@@ -117,7 +117,8 @@
         log.info("%s %s[%s]: omit", host, prefix, ip)
  
 def apply_hosts_forward (hosts, origin,
-        add_origin  = False,
+        add_origin      = False,
+        check_conflicts = False,
 ) :
     """
         Generate DNS ZoneRecords for for hosts within the given zone origin.
@@ -127,6 +128,8 @@
             hosts: [Host]       - Host's to render
             origin: str         - generate records relative to given zone origin
             add_origin: bool    - generate an explicit $ORIGIN directive
+            check_conflits: bool- raise HostZoneError on dupliate records for the same name/type
+                                  overlapping CNAME records will always raise
 
         Yields ZoneRecords in Host-order
     """
@@ -143,7 +146,7 @@
                 raise HostZoneError(host, u"{cname} CNAME conflict with {other}".format(cname=rr.name, other=by_name_type[rr.name, 'CNAME']))
             elif rr.type == 'CNAME' and rr.name in by_name:
                 raise HostZoneError(host, u"{cname} CNAME conflict with {other}".format(cname=rr.name, other=by_name[rr.name]))
-            elif (rr.name, rr.type) in by_name_type:
+            elif check_conflicts and (rr.name, rr.type) in by_name_type:
                 raise HostZoneError(host, u"{name} {type} conflict with {other}".format(type=rr.type, name=rr.name, other=by_name_type[rr.name, rr.type]))
             
             by_name[rr.name] = host