From: Frank Brehm Date: Wed, 17 Jan 2018 14:54:31 +0000 (+0100) Subject: Renaming method is_local() to is_local_domain() X-Git-Tag: 0.1.2~17 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=d59596177e2f41f147dac3cc97ab09f461ccdd05;p=pixelpark%2Fadmin-tools.git Renaming method is_local() to is_local_domain() * renamin in classes ImportPdnsdataApp and PDNSMigrateNsApp * Removing comment on migration in PDNSMigrateNsApp --- diff --git a/pp_lib/import_pdnsdata.py b/pp_lib/import_pdnsdata.py index aa63e31..2d44ebf 100644 --- a/pp_lib/import_pdnsdata.py +++ b/pp_lib/import_pdnsdata.py @@ -31,7 +31,7 @@ from .common import pp, to_bool from .cfg_app import PpCfgAppError, PpConfigApplication -__version__ = '0.8.8' +__version__ = '0.8.9' LOG = logging.getLogger(__name__) # ============================================================================= @@ -639,7 +639,7 @@ class ImportPdnsdataApp(PpConfigApplication): i += 1 dom_id = result['id'] self.domain_ids[dom_id] = result['name'] - if self.is_local(result['name']): + if self.is_local_domain(result['name']): LOG.debug("Setting zone {!r} to a local only zone.".format(result['name'])) cur_account = result['account'] if cur_account is None: diff --git a/pp_lib/pdns_app.py b/pp_lib/pdns_app.py index 38e5fce..fa54c2b 100644 --- a/pp_lib/pdns_app.py +++ b/pp_lib/pdns_app.py @@ -32,7 +32,7 @@ from .cfg_app import PpCfgAppError, PpConfigApplication from .pdns_zone import PdnsApiZone from .pdns_record import PdnsApiRecord, PdnsSoaData, PdnsApiRrset -__version__ = '0.6.2' +__version__ = '0.6.3' LOG = logging.getLogger(__name__) _LIBRARY_NAME = "pp-pdns-api-client" @@ -749,9 +749,16 @@ class PpPDNSApplication(PpConfigApplication): ns_ttl = None if not new_ttl: cur_rrset = zone.get_ns_rrset(for_zone=for_zone) - ns_ttl = cur_rrset.ttl + if cur_rrset: + ns_ttl = cur_rrset.ttl + else: + soa = zone.get_soa() + ns_ttl = soa.ttl + del soa else: ns_ttl = int(new_ttl) + if ns_ttl <= 0: + ns_ttl = 3600 LOG.debug("TTL for NS records: {}.".format(ns_ttl)) rrset_name = zone.name.lower() diff --git a/pp_lib/pdns_migrate_ns.py b/pp_lib/pdns_migrate_ns.py index 5735b81..d367262 100644 --- a/pp_lib/pdns_migrate_ns.py +++ b/pp_lib/pdns_migrate_ns.py @@ -27,7 +27,7 @@ from .pdns_app import PpPDNSAppError, PpPDNSApplication, PDNSApiNotFoundError, P from .pdns_zone import PdnsApiZone from .pdns_record import compare_rrsets -__version__ = '0.2.6' +__version__ = '0.2.7' LOG = logging.getLogger(__name__) @@ -157,7 +157,7 @@ class PDNSMigrateNsApp(PpPDNSApplication): new_nameservers = [] hm_address = self.address_hostmaster_public - is_local = self.is_local(zone_name) + is_local = self.is_local_domain(zone_name) if is_local: LOG.debug("Using local nameservers for substituting.") @@ -189,8 +189,7 @@ class PDNSMigrateNsApp(PpPDNSApplication): LOG.debug("Update SOA of zone is not necessary.".format(zone_name)) LOG.info("Setting nameservers for zone {!r} ...".format(zone_name)) - comment = "Update NS entries on great NS- and SOA-Migration." - if not self.set_nameservers(zone, new_nameservers, comment=comment, do_serial=False): + if not self.set_nameservers(zone, new_nameservers, do_serial=False): return False zone_parts = zone_name.split('.') @@ -208,7 +207,7 @@ class PDNSMigrateNsApp(PpPDNSApplication): z=zone_name, t=top_zone_name)) top_zone = self.get_api_zone(top_zone_name) return self.set_nameservers( - top_zone, new_nameservers, zone_name, comment=comment, do_serial=False) + top_zone, new_nameservers, zone_name, do_serial=False) else: LOG.debug("Top zone {!r} is not in our responsibility.".format(top_zone_name)) return True