import logging
import logging.config
import textwrap
+import copy
from functools import cmp_to_key
from .pdns_zone import PdnsApiZone
from .pdns_record import compare_rrsets
-__version__ = '0.2.3'
+__version__ = '0.2.4'
LOG = logging.getLogger(__name__)
]
new_local_nameservers = [
- 'ns1-local.pixelpark.com',
- 'ns2-local.pixelpark.com',
- 'ns3-local.pixelpark.com',
+ 'ns1-local.pixelpark.com.',
+ 'ns2-local.pixelpark.com.',
+ 'ns3-local.pixelpark.com.',
]
+ address_hostmaster_local = 'hostmaster.pixelpark.com.'
+ address_hostmaster_public = 'hostmaster.pixelpark.net.'
+
# -------------------------------------------------------------------------
def __init__(self, appname=None, version=__version__):
return False
new_nameservers = []
+ hm_address = self.address_hostmaster_public
+
+ is_local = self.is_local(zone_name)
- if self.is_local(zone_name):
+ if is_local:
LOG.debug("Using local nameservers for substituting.")
new_nameservers = sorted(self.new_local_nameservers)
+ hm_address = self.address_hostmaster_local
else:
LOG.debug("Using public nameservers for substituting.")
new_nameservers = sorted(self.new_public_nameservers)
LOG.error("Could not find SOA for zone {!r}.".format(zone_name))
return False
if self.verbose > 2:
- LOG.debug("SOA of zone {!r}:\n{}".format(zone_name, soa))
+ LOG.debug("Current SOA of zone {!r}:\n{}".format(zone_name, soa))
+
+ new_soa = copy.copy(soa)
+ new_soa.primary = new_nameservers[0]
+ new_soa.email = hm_address
+ if self.verbose > 2:
+ LOG.debug("New SOA of zone {!r}:\n{}".format(zone_name, new_soa))
+
+ if new_soa != soa:
+ self.ensure_soa(zone, new_soa)
+ else:
+ LOG.debug("Update SOA of zone is not necessary.".format(zone_name))
if not self.ensure_nameservers(zone, new_nameservers):
return False
LOG.debug("Top zone {!r} is not in our responsibility.".format(top_zone_name))
return True
+ # -------------------------------------------------------------------------
+ def ensure_soa(self, zone, new_soa):
+
+ LOG.info("Updating SOA of zone {z!r} with {s!r} ...".format(
+ z=zone.name, s=new_soa.data))
+
+ self.update_soa(zone, new_soa, "Update on great NS- and SOA-Migration.")
+
# -------------------------------------------------------------------------
def ensure_nameservers(self, zone, new_nameservers, for_zone=None):