From: Frank Brehm Date: Thu, 18 Jan 2018 12:05:31 +0000 (+0100) Subject: Adding possibility to modify pause between zones X-Git-Tag: 0.1.2~14 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=8bd5ad9e98b4bbd6d13a53fc1a449fef6c24c1ee;p=pixelpark%2Fadmin-tools.git Adding possibility to modify pause between zones --- diff --git a/pp_lib/pdns_migrate_ns.py b/pp_lib/pdns_migrate_ns.py index d367262..693cc37 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.7' +__version__ = '0.2.8' LOG = logging.getLogger(__name__) @@ -58,12 +58,15 @@ class PDNSMigrateNsApp(PpPDNSApplication): address_hostmaster_local = 'hostmaster.pixelpark.com.' address_hostmaster_public = 'hostmaster.pixelpark.net.' + default_pause = 3 + # ------------------------------------------------------------------------- def __init__(self, appname=None, version=__version__): self.zones = [] self.zone_names = [] self.oneshot = False + self.pause = self.default_pause description = textwrap.dedent('''\ Substituting NS records in all zones by the new ones. @@ -93,6 +96,14 @@ class PDNSMigrateNsApp(PpPDNSApplication): help="Stop execution after first successful migration." ) + self.arg_parser.add_argument( + '--pause', dest='pause', type=int, + default=self.default_pause, metavar='SECS', + help=( + "Pause in seconds between mangling the particular zones. " + "(Default: %(default)r)."), + ) + self.arg_parser.add_argument( 'zones', metavar='ZONE', nargs='*', help=( @@ -112,6 +123,9 @@ class PDNSMigrateNsApp(PpPDNSApplication): if self.args.oneshot: self.oneshot = True + if self.args.pause and self.args.pause > 0: + self.pause = self.args.pause + for zone in self.args.zones: zone_idna = zone if 'xn--' not in zone: @@ -137,9 +151,9 @@ class PDNSMigrateNsApp(PpPDNSApplication): if idx: print('') print('') - print('Sleeping a little bit ...') + print('Sleeping {} seconds...'.format(self.pause)) print('') - time.sleep(3) + time.sleep(self.pause) migrated = self.migrate_zone(zone_name) if migrated: idx += 1