]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Adding possibility to modify pause between zones
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 18 Jan 2018 12:05:31 +0000 (13:05 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 18 Jan 2018 12:05:31 +0000 (13:05 +0100)
pp_lib/pdns_migrate_ns.py

index d36726282abcde25d283f6fd35da192442fad29b..693cc3758add9a75b46739bf9c593275a0632224 100644 (file)
@@ -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