]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Adding bin/pdns-show-zone and pp_lib/pdns_show_zone.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 8 Nov 2017 12:17:43 +0000 (13:17 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 8 Nov 2017 12:17:43 +0000 (13:17 +0100)
bin/pdns-show-zone [new file with mode: 0755]
pp_lib/pdns_show_zone.py [new file with mode: 0644]

diff --git a/bin/pdns-show-zone b/bin/pdns-show-zone
new file mode 100755 (executable)
index 0000000..f437b28
--- /dev/null
@@ -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_show_zone import PpPDNSShowZoneApp
+
+log = logging.getLogger(__name__)
+
+__author__ = 'Frank Brehm <frank.brehm@pixelpark.com>'
+__copyright__ = '(C) 2017 by Frank Brehm, Pixelpark GmbH, Berlin'
+
+appname = os.path.basename(sys.argv[0])
+
+locale.setlocale(locale.LC_ALL, '')
+
+app = PpPDNSShowZoneApp(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_show_zone.py b/pp_lib/pdns_show_zone.py
new file mode 100644 (file)
index 0000000..6a06fcc
--- /dev/null
@@ -0,0 +1,71 @@
+#!/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-show-zone application object.
+"""
+from __future__ import absolute_import
+
+# Standard modules
+import os
+import logging
+import logging.config
+import textwrap
+
+from functools import cmp_to_key
+
+# Own modules
+from .common import pp, compare_fqdn
+
+from .pdns_app import PpPDNSAppError, PpPDNSApplication
+from .pdns_zone import PdnsApiZone
+
+__version__ = '0.1.0'
+LOG = logging.getLogger(__name__)
+
+
+# =============================================================================
+class PpPDNSShowZoneError(PpPDNSAppError):
+    pass
+
+
+# =============================================================================
+class PpPDNSShowZoneApp(PpPDNSApplication):
+    """Class for the 'pdns-show-zone' application to get all information about
+       a given zone from PowerDNS.
+    """
+
+    # -------------------------------------------------------------------------
+    def __init__(self, appname=None, version=__version__):
+
+        self.zone = None
+
+        description = textwrap.dedent('''\
+            Lists all available zones from given PowerDNS API.
+            ''')
+
+        super(PpPDNSShowZoneApp, self).__init__(
+            appname=appname, version=version, description=description,
+        )
+
+        self.initialized = True
+
+    # -------------------------------------------------------------------------
+    def _run(self):
+
+        LOG.info("Show all information about zone {!r} from PowerDNS environment {!r}.".format(
+            self.zone, self.environment))
+
+
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+    pass
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list