]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Finishing configuration of zone masters
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 11 Dec 2017 18:04:21 +0000 (19:04 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 11 Dec 2017 18:04:21 +0000 (19:04 +0100)
pp_lib/deploy_zones_from_pdns.py

index 84557f53f80ee6a0103bb39eda50f5c73ee4de0e..afba2efaa378b86a6f90663668ebad3e4cf3125f 100644 (file)
@@ -44,7 +44,7 @@ from .pdns_record import compare_rrsets
 
 from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
 
-__version__ = '0.5.1'
+__version__ = '0.5.2'
 LOG = logging.getLogger(__name__)
 
 
@@ -268,14 +268,22 @@ class PpDeployZonesApp(PpPDNSApplication):
         for m in self.re_split_addresses.split(value):
             if m:
                 m = m.strip().lower()
+                LOG.debug("Checking given master address {!r} ...".format(m))
                 try:
                     addr_infos = socket.getaddrinfo(
                         m, 53, proto=socket.IPPROTO_TCP)
                     for addr_info in addr_infos:
+                        addr = addr_info[4][0]
                         if not self.named_listen_on_v6 and addr_info[0] == socket.AF_INET6:
+                            msg = (
+                                "Not using {!r} as a master IP address, because "
+                                "we are not using IPv6.").format(addr)
+                            LOG.debug(msg)
                             continue
-                        addr = addr_info[4][0]
-                        if addr not in masters and addr not in self.local_addresses:
+                        if addr in masters:
+                            LOG.debug("Address {!r} already in masters yet.".format(addr))
+                        else:
+                            LOG.debug("Address {!r} not in masters yet.".format(addr))
                             masters.append(addr)
 
                 except socket.gaierror as e:
@@ -301,6 +309,19 @@ class PpDeployZonesApp(PpPDNSApplication):
 
         LOG.debug("Post init phase.")
 
+        LOG.debug("Checking for masters, which are local addresses ...")
+        ext_masters = []
+        for addr in self.zone_masters:
+            if addr in self.local_addresses:
+                LOG.debug(
+                    "Address {!r} IS in list of local addresses.".format(addr))
+            else:
+                LOG.debug(
+                    "Address {!r} not in list of local addresses.".format(addr))
+                ext_masters.append(addr)
+        self.zone_masters = ext_masters
+        LOG.info("Using list of masters for slave zones:\n{}".format(pp(self.zone_masters)))
+
         self.pidfile = PidFile(
             filename=self.pidfile_name, appname=self.appname, verbose=self.verbose,
             base_dir=self.base_dir, simulate=self.simulate)