From 76c91a062ec9aaca044edee09af543a782a952e5 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 7 Nov 2017 19:28:07 +0100 Subject: [PATCH] First output of zone list --- pp_lib/pdns_list_zones.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pp_lib/pdns_list_zones.py b/pp_lib/pdns_list_zones.py index ddbd77c..ad8f41f 100644 --- a/pp_lib/pdns_list_zones.py +++ b/pp_lib/pdns_list_zones.py @@ -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)) # ============================================================================= -- 2.39.5