from .common import pp, to_bool
from .cfg_app import PpCfgAppError, PpConfigApplication
+from .pdns_zone import PdnsApiZone
-__version__ = '0.3.1'
+__version__ = '0.3.2'
LOG = logging.getLogger(__name__)
_LIBRARY_NAME = "pp-pdns-api-client"
return json_response
+ # -------------------------------------------------------------------------
+ def get_api_zones(self):
+
+ LOG.debug("Trying to get all zones from PDNS API ...")
+
+ path = "/servers/{}/zones".format(self.api_servername)
+ json_response = self.perform_request(path)
+ if self.verbose > 2:
+ LOG.debug("Got a response:\n{}".format(pp(json_response)))
+
+ zone_list = []
+
+ 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 self.verbose > 2:
+ print("{!r}".format(zone))
+ return zone_list
# =============================================================================
from .pdns_app import PpPDNSAppError, PpPDNSApplication
from .pdns_zone import PdnsApiZone
-__version__ = '0.2.3'
+__version__ = '0.3.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def _run(self):
- LOG.info("Listing all available zones from PowerrDNS environment {!r}.".format(
+ LOG.info("Listing all available zones from PowerDNS environment {!r}.".format(
self.environment))
- path = "/servers/{}/zones".format(self.api_servername)
- json_response = self.perform_request(path)
- if self.verbose > 2:
- LOG.debug("Got a response:\n{}".format(pp(json_response)))
+ zone_list = self.get_api_zones()
- 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)
+ for zone in zone_list:
if len(zone.name_unicode) > len_zone:
len_zone = len(zone.name_unicode)
- 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",