From 9eddd0744393dfaf3439026baaa54e47cfcaac09 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 7 Nov 2017 17:28:57 +0100 Subject: [PATCH] Adding bin/pdns-list-zones and pp_lib/pdns_list_zones.py --- bin/pdns-list-zones | 41 ++++++++++++++++++++++++ pp_lib/pdns_list_zones.py | 66 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100755 bin/pdns-list-zones create mode 100644 pp_lib/pdns_list_zones.py diff --git a/bin/pdns-list-zones b/bin/pdns-list-zones new file mode 100755 index 0000000..40e10da --- /dev/null +++ b/bin/pdns-list-zones @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +# Standard modules +import sys +import os +import logging +import locale + +# own modules: +cur_dir = os.getcwd() +base_dir = cur_dir + +if sys.argv[0] != '' and sys.argv[0] != '-c': + bin_dir = os.path.dirname(sys.argv[0]) +base_dir = os.path.abspath(os.path.join(bin_dir, '..')) +module_dir = os.path.join(base_dir, 'pp_lib') +if os.path.exists(module_dir): + sys.path.insert(0, base_dir) + +from pp_lib.pdns_list_zones import PpPDNSListZonesApp + +log = logging.getLogger(__name__) + +__author__ = 'Frank Brehm ' +__copyright__ = '(C) 2017 by Frank Brehm, Pixelpark GmbH, Berlin' + +appname = os.path.basename(sys.argv[0]) + +locale.setlocale(locale.LC_ALL, '') + +app = PpPDNSListZonesApp(appname=appname) +app.initialized = True + +if app.verbose > 2: + print("{c}-Object:\n{a}".format(c=app.__class__.__name__, a=app)) + +app() + +sys.exit(0) + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list diff --git a/pp_lib/pdns_list_zones.py b/pp_lib/pdns_list_zones.py new file mode 100644 index 0000000..2bf1921 --- /dev/null +++ b/pp_lib/pdns_list_zones.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +@author: Frank Brehm +@contact: frank.brehm@pixelpark.com +@copyright: © 2017 by Frank Brehm, Berlin +@summary: The module for the pdns-list-zones application object. +""" +from __future__ import absolute_import + +# Standard modules +import os +import logging +import logging.config +import textwrap + +# Own modules +from .common import pp + +from .pdns_app import PpPDNSAppError, PpPDNSApplication + +__version__ = '0.1.0' +LOG = logging.getLogger(__name__) + + +# ============================================================================= +class PpPDNSListZonesError(PpPDNSAppError): + pass + + +# ============================================================================= +class PpPDNSListZonesApp(PpPDNSApplication): + """Class for the 'pdns-list-zones' application get a list of all available + zones from PowerDNS + """ + + # ------------------------------------------------------------------------- + def __init__(self, appname=None, version=__version__): + + description = textwrap.dedent('''\ + Lists all available zones from given PowerDNS API. + ''') + + super(PpPDNSListZonesApp, self).__init__( + appname=appname, version=version, description=description, + ) + + self.initialized = True + + # ------------------------------------------------------------------------- + def _run(self): + + LOG.info("Listing all available zones from PowerrDNS environment {!r}.".format( + self.environment)) + + + +# ============================================================================= + +if __name__ == "__main__": + + pass + +# ============================================================================= + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list -- 2.39.5