From fd7e04aee21feac2bf7287edb8754b55ab5f3e0e Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 7 Aug 2017 13:53:44 +0200 Subject: [PATCH] Changing properties --- pp_lib/config_named_app.py | 195 ++++++++++++++++++++++++++++++------- 1 file changed, 162 insertions(+), 33 deletions(-) diff --git a/pp_lib/config_named_app.py b/pp_lib/config_named_app.py index 0c961d8..4dea5f5 100644 --- a/pp_lib/config_named_app.py +++ b/pp_lib/config_named_app.py @@ -38,7 +38,7 @@ from .cfg_app import PpCfgAppError, PpConfigApplication from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile -__version__ = '0.5.1' +__version__ = '0.5.2' LOG = logging.getLogger(__name__) @@ -119,24 +119,24 @@ class PpConfigNamedApp(PpConfigApplication): # Configuration files and directories self.named_conf_dir = self.default_named_conf_dir self._named_conf = self.default_named_conf - 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 + 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 + 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 + self._named_pidfile = self.default_named_pidfile + self._named_session_keyfile = self.default_named_session_keyfile # Runtime user and group self.named_user = 'named' @@ -181,6 +181,120 @@ class PpConfigNamedApp(PpConfigApplication): """The named.conf as an absolute pathname.""" return os.path.join(self.named_conf_dir, self._named_conf) + # ------------------------------------------- + @property + def named_acl_cfg_file(self): + """The config file for ACLs as an absolute pathname.""" + return os.path.join(self.named_conf_dir, self._named_acl_cfg_file) + + # ------------------------------------------- + @property + def named_bindkeys_file(self): + """The file for bind keys.""" + return os.path.join(self.named_conf_dir, self._named_bindkeys_file) + + # ------------------------------------------- + @property + def named_rootkeys_file(self): + """The file for root keys.""" + return os.path.join(self.named_conf_dir, self._named_rootkeys_file) + + # ------------------------------------------- + @property + def named_def_zones_file(self): + """The file for default zones.""" + return os.path.join(self.named_conf_dir, self._named_def_zones_file) + + # ------------------------------------------- + @property + def named_log_cfg_file(self): + """The file for logging configuration.""" + return os.path.join(self.named_conf_dir, self._named_log_cfg_file) + + # ------------------------------------------- + @property + def named_zones_cfg_file(self): + """The file for configuration of all own zones.""" + return os.path.join(self.named_conf_dir, self._named_zones_cfg_file) + + # ------------------------------------------- + @property + def named_pidfile(self): + """The PID file for the named daemon.""" + return os.path.join(self.named_rundir, self._named_pidfile) + + # ------------------------------------------- + @property + def named_session_keyfile(self): + """The file for the named session key.""" + return os.path.join(self.named_rundir, self._named_session_keyfile) + + # ------------------------------------------- + @property + def named_datadir_abs(self): + """The directory for additional data of named.""" + return os.path.join(self.named_basedir, self._named_datadir) + + # ------------------------------------------- + @property + def named_datadir_rel(self): + """The directory for additional data of named.""" + return self._named_datadir + + # ------------------------------------------- + @property + def named_dump_dir(self): + """Directory name of the named dump file.""" + return os.path.join(self.named_basedir, 'dump') + + # ------------------------------------------- + @property + def named_dump_file(self): + """File name of the named dump file.""" + return os.path.join(self.named_dump_dir, 'named_dump.db') + + # ------------------------------------------- + @property + def named_stats_dir(self): + """Directory name of the named statistics.""" + return os.path.join(self.named_basedir, 'stats') + + # ------------------------------------------- + @property + def named_stats_file(self): + """File name of the named statistics file.""" + return os.path.join(self.named_stats_dir, 'named.stats') + + # ------------------------------------------- + @property + def named_slavedir_rel(self): + """The directory for zone files of slave zones.""" + return self._named_slavedir + + # ------------------------------------------- + @property + def named_slavedir_abs(self): + """The directory for zone files of slave zones.""" + return os.path.join(self.named_basedir, self._named_slavedir) + + # ------------------------------------------- + @property + def named_root_zone_file_rel(self): + """The filename of the root zone.""" + return self._named_root_zone_file + + # ------------------------------------------- + @property + def named_root_zone_file_abs(self): + """The filename of the root zone.""" + return os.path.join(self.named_basedir, self._named_root_zone_file) + + # ------------------------------------------- + @property + def named_managed_keysdir(self): + """The directory for managed session keys.""" + return os.path.join(self.named_basedir, self._named_managed_keysdir) + # ------------------------------------------------------------------------- def as_dict(self, short=True): """ @@ -195,6 +309,25 @@ class PpConfigNamedApp(PpConfigApplication): res = super(PpConfigNamedApp, self).as_dict(short=short) res['named_conf'] = self.named_conf + res['named_acl_cfg_file'] = self.named_acl_cfg_file + res['named_pidfile'] = self.named_pidfile + res['named_session_keyfile'] = self.named_session_keyfile + res['named_bindkeys_file'] = self.named_bindkeys_file + res['named_rootkeys_file'] = self.named_rootkeys_file + res['named_def_zones_file'] = self.named_def_zones_file + res['named_log_cfg_file'] = self.named_log_cfg_file + res['named_zones_cfg_file'] = self.named_zones_cfg_file + res['named_dump_dir'] = self.named_dump_dir + res['named_dump_file'] = self.named_dump_file + res['named_stats_dir'] = self.named_stats_dir + res['named_stats_file'] = self.named_stats_file + res['named_datadir_abs'] = self.named_datadir_abs + res['named_datadir_rel'] = self.named_datadir_rel + res['named_slavedir_abs'] = self.named_slavedir_abs + res['named_slavedir_rel'] = self.named_slavedir_rel + res['named_managed_keysdir'] = self.named_managed_keysdir + res['named_root_zone_file_rel'] = self.named_root_zone_file_rel + res['named_root_zone_file_abs'] = self.named_root_zone_file_abs 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 @@ -352,32 +485,32 @@ class PpConfigNamedApp(PpConfigApplication): 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) + section, section_name, 'bindkeys_file', '_named_bindkeys_file', False) self._check_path_config( - section, section_name, 'rootkeys_file', 'named_rootkeys_file', False) + section, section_name, 'rootkeys_file', '_named_rootkeys_file', False) self._check_path_config( - section, section_name, 'default_zones_file', 'named_def_zones_file', False) + 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) + 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) + 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) + 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, 'data_dir', '_named_datadir', False) + self._check_path_config(section, section_name, 'slave_dir', '_named_slavedir', False) self._check_path_config( - section, section_name, 'managed_keys_dir', 'named_managed_keysdir', False) + 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) + 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, 'pidfile', '_named_pidfile', False) self._check_path_config( - section, section_name, 'session_keyfile', 'named_session_keyfile', False) + section, section_name, 'session_keyfile', '_named_session_keyfile', False) # Logging configuration self._check_path_config(section, section_name, 'log_dir', 'named_logdir', True) @@ -573,10 +706,6 @@ class PpConfigNamedApp(PpConfigApplication): cur_date = datetime.datetime.now().isoformat(' ') - acl_file = os.path.join(self.named_conf_dir, self.named_acl_cfg_file) - named_pidfile = os.path.join(self.named_rundir, self.named_pidfile) - dump_dir = os.path.join(self.named_basedir, 'dump') - dump_file = os.path.join(dump_dir, 'named_dump.db') stats_dir = os.path.join(self.named_basedir, 'stats') stats_file = os.path.join(stats_dir, 'named.stats') @@ -601,7 +730,7 @@ class PpConfigNamedApp(PpConfigApplication): content = header content += '\n// access control lists\n' - content += 'include "{}";\n'.format(acl_file) + content += 'include "{}";\n'.format(self.named_acl_cfg_file) option_lines = [] option_lines.append('options {') @@ -614,9 +743,9 @@ class PpConfigNamedApp(PpConfigApplication): option_lines.append('\trecursion no;') option_lines.append('') option_lines.append('\tdirectory "{}";'.format(self.named_basedir)) - option_lines.append('\tpid-file "{}";'.format(named_pidfile)) - option_lines.append('\tdump-file "{}";'.format(dump_file)) - option_lines.append('\tstatistics-file "{}";'.format(stats_file)) + option_lines.append('\tpid-file "{}";'.format(self.named_pidfile)) + option_lines.append('\tdump-file "{}";'.format(self.named_dump_file)) + option_lines.append('\tstatistics-file "{}";'.format(self.named_stats_file)) option_lines.append('') option_lines.append('\t// DNSSEC') -- 2.39.5