]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
First output of zone list
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 7 Nov 2017 18:28:07 +0000 (19:28 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 7 Nov 2017 18:28:07 +0000 (19:28 +0100)
pp_lib/pdns_list_zones.py

index ddbd77cee20527fa233eb628b3e675d9bb6ead53..ad8f41fea4f28e01159cbdd32695c2c172d7361f 100644 (file)
@@ -18,8 +18,9 @@ import textwrap
 from .common import pp
 
 from .pdns_app import PpPDNSAppError, PpPDNSApplication
+from .pdns_zone import PdnsApiZone
 
-__version__ = '0.2.0'
+__version__ = '0.2.1'
 LOG = logging.getLogger(__name__)
 
 
@@ -58,6 +59,26 @@ class PpPDNSListZonesApp(PpPDNSApplication):
         if self.verbose > 2:
             LOG.debug("Got a response:\n{}".format(pp(json_response)))
 
+        zone_list = []
+        len_zone = 10
+
+        for data in json_response:
+            zone = PdnsApiZone.init_from_dict(
+                data, appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+            zone_list.append(zone)
+            if len(zone.name) > len_zone:
+                len_zone = len(zone.name)
+            if self.verbose > 2:
+                print("{!r}".format(zone))
+        tpl = PdnsApiZone.get_list_template()
+        line = tpl.format(
+            name="Zone", len_zone=len_zone, kind="Type", serial="Serial",
+            dnssec="DNSSEC", account="Account information")
+        print(line)
+        print('-' * len(line))
+
+        for zone in zone_list:
+            print(zone.get_line(len_zone))
 
 # =============================================================================