from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.3.2'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
Class for a application 'config-named' for configuring the BIND named daemon.
"""
+ default_pidfile = '/run/dns-deploy-zones.pid'
+
default_pdns_api_host = 'systemshare.pixelpark.com'
default_pdns_api_port = 8081
default_pdns_api_root_path = '/api/v1'
default_pdns_api_server_id = 'localhost'
- default_named_conf = '/etc/named.conf'
- default_named_zones_cfg_dir = '/etc/named'
+
+ default_named_conf_dir = '/etc'
+ default_named_conf = 'named.conf'
+ default_named_bindkeys_file = 'named.iscdlv.key'
+ default_named_rootkeys_file = 'named.root.key'
+ default_named_def_zones_file = 'named.rfc1912.zones'
+ default_named_acl_cfg_file = 'named.acl.conf'
+ default_named_log_cfg_file = 'named.log.conf'
+ default_named_zones_cfg_file = 'named.zones.conf'
+
default_named_basedir = '/var/named'
- default_named_datadir = os.path.join(default_named_basedir, 'data')
- default_named_slavedir = os.path.join(default_named_basedir, 'slaves')
- default_named_iscdlv_key_file = '/etc/named.iscdlv.key'
+ default_named_datadir = 'data'
+ default_named_slavedir = 'slaves'
+ default_named_managed_keysdir = 'dynamic'
+ default_named_root_zone_file = 'named.ca'
+
default_named_rundir = '/run/named'
+ default_named_pidfile = 'named.pid'
+ default_named_session_keyfile = 'session.key'
+
+ default_named_log_dir = '/var/log/named'
+
default_named_version2show = 'none'
default_zone_masters = [
re_ipv4_zone = re.compile(r'^((?:\d+\.)+)in-addr\.arpa\.$')
re_ipv6_zone = re.compile(r'^((?:[\da-f]\.)+)ip6\.arpa\.$')
+ open_args = {}
+ if six.PY3:
+ open_args = {
+ 'encoding': 'utf-8',
+ 'errors': 'surrogateescape',
+ }
+
# -------------------------------------------------------------------------
def __init__(self, appname=None, version=__version__):
+ self._show_simulate_opt = True
+
+ self.pidfile = self.default_pidfile
+
self.pdns_api_host = self.default_pdns_api_host
self.pdns_api_port = self.default_pdns_api_port
self.pdns_api_root_path = self.default_pdns_api_root_path
self.is_internal = False
self.named_listen_on_v6 = False
+
+ # Configuration files and directories
+ self.named_conf_dir = self.default_named_conf_dir
self.named_conf = self.default_named_conf
- self.named_zones_cfg_dir = self.default_named_zones_cfg_dir
- self.zone_masters = copy.copy(self.default_zone_masters)
+ self.named_bindkeys_file = self.default_named_bindkeys_file
+ self.named_rootkeys_file = self.default_named_rootkeys_file
+ self.named_def_zones_file = self.default_named_def_zones_file
+ self.named_acl_cfg_file = self.default_named_acl_cfg_file
+ self.named_log_cfg_file = self.default_named_log_cfg_file
+ self.named_zones_cfg_file = self.default_named_zones_cfg_file
+
+ # Variable status directories and files
+ self.named_basedir = self.default_named_basedir
+ self.named_datadir = self.default_named_datadir
+ self.named_slavedir = self.default_named_slavedir
+ self.named_managed_keysdir = self.default_named_managed_keysdir
+ self.named_root_zone_file = self.default_named_root_zone_file
+
+ # Runtime volatile directories and files
+ self.named_rundir = self.default_named_rundir
+ self.named_pidfile = self.default_named_pidfile
+ self.named_session_keyfile = self.default_named_session_keyfile
+ # Runtime user and group
self.named_user = 'named'
self.named_uid = None
self.named_group = 'named'
self.named_gid = None
- self.named_basedir = self.default_named_basedir
- self.named_datadir = self.default_named_datadir
- self.named_slavedir = self.default_named_slavedir
- self.named_iscdlv_key_file = self.default_named_iscdlv_key_file
- self.named_rundir = self.default_named_rundir
-
self.named_dnssec = False
+ # Logging configuration
self.named_logdir = '/var/log/named'
self.query_log = False
self.named_show_bind_version = False
self.named_version2show = self.default_named_version2show
+ self.zone_masters = copy.copy(self.default_zone_masters)
+
self.zones = []
description = textwrap.dedent('''\
self.post_init()
+ # -------------------------------------------------------------------------
+ def as_dict(self, short=True):
+ """
+ Transforms the elements of the object into a dict
+
+ @param short: don't include local properties in resulting dict.
+ @type short: bool
+
+ @return: structure as dict
+ @rtype: dict
+ """
+
+ res = super(PpConfigNamedApp, self).as_dict(short=short)
+ res['default_pidfile'] = self.default_pidfile
+ res['default_pdns_api_host'] = self.default_pdns_api_host
+ res['default_pdns_api_port'] = self.default_pdns_api_port
+ res['default_pdns_api_root_path'] = self.default_pdns_api_root_path
+ res['default_pdns_api_server_id'] = self.default_pdns_api_server_id
+ res['default_named_conf_dir'] = self.default_named_conf_dir
+ res['default_named_conf'] = self.default_named_conf
+ res['default_named_bindkeys_file'] = self.default_named_bindkeys_file
+ res['default_named_rootkeys_file'] = self.default_named_rootkeys_file
+ res['default_named_def_zones_file'] = self.default_named_def_zones_file
+ res['default_named_acl_cfg_file'] = self.default_named_acl_cfg_file
+ res['default_named_log_cfg_file'] = self.default_named_log_cfg_file
+ res['default_named_zones_cfg_file'] = self.default_named_zones_cfg_file
+ res['default_named_basedir'] = self.default_named_basedir
+ res['default_named_datadir'] = self.default_named_datadir
+ res['default_named_slavedir'] = self.default_named_slavedir
+ res['default_named_managed_keysdir'] = self.default_named_managed_keysdir
+ res['default_named_root_zone_file'] = self.default_named_root_zone_file
+ res['default_named_rundir'] = self.default_named_rundir
+ res['default_named_pidfile'] = self.default_named_pidfile
+ res['default_named_session_keyfile'] = self.default_named_session_keyfile
+ res['default_named_log_dir'] = self.default_named_log_dir
+ res['default_named_version2show'] = self.default_named_version2show
+ res['default_zone_masters'] = copy.copy(self.default_zone_masters)
+ res['re_split_addresses'] = self.re_split_addresses
+ res['re_integer'] = self.re_integer
+ res['re_ipv4_zone'] = self.re_ipv4_zone
+ res['re_ipv6_zone'] = self.re_ipv6_zone
+ res['open_args'] = self.open_args
+
+ return res
+
# -------------------------------------------------------------------------
def init_arg_parser(self):
section = self.cfg[section_name]
+ if section_name.lower() == 'app':
+ self._check_path_config(section, section_name, 'pidfile', 'pidfile', True)
+
if section_name.lower() in (
'powerdns-api', 'powerdns_api', 'powerdnsapi',
'pdns-api', 'pdns_api', 'pdnsapi' ):
else:
self.is_internal = to_bool(section['is_internal'])
- if 'query_log' in section:
- self.query_log = to_bool(section['query_log'])
-
if 'listen_on_v6' in section and section['listen_on_v6'] is not None:
self.named_listen_on_v6 = to_bool(section['listen_on_v6'])
if 'dnssec' in section and section['dnssec'] is not None:
self.named_dnssec = to_bool(section['dnssec'])
- self._check_path_config(section, section_name, 'named_conf', 'named_conf', True)
- self._check_path_config(section, section_name, 'zones_cfg_dir', 'named_zones_cfg_dir', True)
+ # Configuration files and directories
+ self._check_path_config(section, section_name, 'config_dir', 'named_conf_dir', True)
+ self._check_path_config(section, section_name, 'named_conf', 'named_conf', False)
+ self._check_path_config(
+ section, section_name, 'bindkeys_file', 'named_bindkeys_file', False)
+ self._check_path_config(
+ section, section_name, 'rootkeys_file', 'named_rootkeys_file', False)
+ self._check_path_config(
+ section, section_name, 'default_zones_file', 'named_def_zones_file', False)
+ self._check_path_config(
+ section, section_name, 'acl_cfg_file', 'named_acl_cfg_file', False)
+ self._check_path_config(
+ section, section_name, 'log_cfg_file', 'named_log_cfg_file', False)
+ self._check_path_config(
+ section, section_name, 'zones_cfg_file', 'named_zones_cfg_file', False)
+
+ # Variable status directories and files
self._check_path_config(section, section_name, 'base_dir', 'named_basedir', True)
self._check_path_config(section, section_name, 'data_dir', 'named_datadir', False)
self._check_path_config(section, section_name, 'slave_dir', 'named_slavedir', False)
self._check_path_config(
- section, section_name, 'iscdlv_key_file', 'named_iscdlv_key_file', True)
+ section, section_name, 'managed_keys_dir', 'named_managed_keysdir', False)
+ self._check_path_config(
+ section, section_name, 'root_zone_file', 'named_root_zone_file', False)
+
+ # Runtime volatile directories and files
self._check_path_config(section, section_name, 'run_dir', 'named_rundir', True)
+ self._check_path_config(section, section_name, 'pidfile', 'named_pidfile', False)
+ self._check_path_config(
+ section, section_name, 'session_keyfile', 'named_session_keyfile', False)
+
+ # Logging configuration
self._check_path_config(section, section_name, 'log_dir', 'named_logdir', True)
+ if 'query_log' in section:
+ self.query_log = to_bool(section['query_log'])
if 'show_bind_version' in section and section['show_bind_version'] is not None:
self.named_show_bind_version = to_bool(section['show_bind_version'])
if 'version_to_show' in section and section['version_to_show'] is not None:
self.named_version2show = section['version_to_show'].strip()
+ # Runtime user and group
if 'named_user' in section and section['named_user'] is not None:
self.named_user = section['named_user'].strip()
if 'named_group' in section and section['named_group'] is not None: