From a28837d7e9e9fdbb7ca5d8e2bce8e2747153e1a8 Mon Sep 17 00:00:00 2001 From: stroeder Date: Thu, 3 Aug 2017 17:26:59 +0000 Subject: [PATCH] added new SlapdObject methods _ln_schema_files() and _create_sub_dirs() --- CHANGES | 5 +++-- Lib/slapdtest.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 777193e..28aa7a9 100644 --- a/CHANGES +++ b/CHANGES @@ -4,7 +4,8 @@ Released 2.4.42 2017-08-xx Changes since 2.4.41: Lib/ -* +* added new SlapdObject methods _ln_schema_files() and + _create_sub_dirs() ---------------------------------------------------------------- Released 2.4.41 2017-07-12 @@ -1468,4 +1469,4 @@ Released 2.0.0pre02 2002-02-01 ---------------------------------------------------------------- Released 1.10alpha3 2000-09-19 -$Id: CHANGES,v 1.453 2017/08/03 17:24:43 stroeder Exp $ +$Id: CHANGES,v 1.454 2017/08/03 17:26:59 stroeder Exp $ diff --git a/Lib/slapdtest.py b/Lib/slapdtest.py index 26432cc..28ac86e 100644 --- a/Lib/slapdtest.py +++ b/Lib/slapdtest.py @@ -4,13 +4,13 @@ See http://www.python-ldap.org/ for details. -$Id: slapdtest.py,v 1.14 2017/07/12 17:30:12 stroeder Exp $ +$Id: slapdtest.py,v 1.15 2017/08/03 17:26:59 stroeder Exp $ Python compability note: This module only works with Python 2.7.x since """ -__version__ = '2.4.41' +__version__ = '2.4.42' import os import socket @@ -99,6 +99,10 @@ class SlapdObject(object): # use SASL/EXTERNAL via LDAPI when invoking OpenLDAP CLI tools cli_sasl_external = True local_host = '127.0.0.1' + testrunsubdirs = (()) + openldap_schema_files = ( + 'core.schema', + ) TMPDIR = os.environ.get('TMP', os.getcwd()) SBINDIR = os.environ.get('SBIN', '/usr/sbin') @@ -133,6 +137,8 @@ def _setup_rundir(self): """ os.mkdir(self.testrundir) os.mkdir(self._db_directory) + self._create_sub_dirs(self.testrunsubdirs) + self._ln_schema_files(self.openldap_schema_files, self.SCHEMADIR) def _cleanup_rundir(self): """ @@ -183,6 +189,25 @@ def _gen_config(self): } return self.slapd_conf_template % config_dict + def _create_sub_dirs(self, dir_names): + """ + create sub-directories beneath self.testrundir + """ + for dname in dir_names: + dir_name = os.path.join(self.testrundir, dname) + self._log.debug('Create directory %s', dir_name) + os.mkdir(dir_name) + + def _ln_schema_files(self, file_names, source_dir): + """ + write symbolic links to original schema files + """ + for fname in file_names: + ln_source = os.path.join(source_dir, fname) + ln_target = os.path.join(self._schema_prefix, fname) + self._log.debug('Create symlink %s -> %s', ln_source, ln_target) + os.symlink(ln_source, ln_target) + def _write_config(self): """Writes the slapd.conf file out, and returns the path to it.""" self._log.debug('Writing config to %s', self._slapd_conf)