|
4 | 4 |
|
5 | 5 | See http://www.python-ldap.org/ for details. |
6 | 6 |
|
7 | | -$Id: slapdtest.py,v 1.14 2017/07/12 17:30:12 stroeder Exp $ |
| 7 | +$Id: slapdtest.py,v 1.15 2017/08/03 17:26:59 stroeder Exp $ |
8 | 8 |
|
9 | 9 | Python compability note: |
10 | 10 | This module only works with Python 2.7.x since |
11 | 11 | """ |
12 | 12 |
|
13 | | -__version__ = '2.4.41' |
| 13 | +__version__ = '2.4.42' |
14 | 14 |
|
15 | 15 | import os |
16 | 16 | import socket |
@@ -99,6 +99,10 @@ class SlapdObject(object): |
99 | 99 | # use SASL/EXTERNAL via LDAPI when invoking OpenLDAP CLI tools |
100 | 100 | cli_sasl_external = True |
101 | 101 | local_host = '127.0.0.1' |
| 102 | + testrunsubdirs = (()) |
| 103 | + openldap_schema_files = ( |
| 104 | + 'core.schema', |
| 105 | + ) |
102 | 106 |
|
103 | 107 | TMPDIR = os.environ.get('TMP', os.getcwd()) |
104 | 108 | SBINDIR = os.environ.get('SBIN', '/usr/sbin') |
@@ -133,6 +137,8 @@ def _setup_rundir(self): |
133 | 137 | """ |
134 | 138 | os.mkdir(self.testrundir) |
135 | 139 | os.mkdir(self._db_directory) |
| 140 | + self._create_sub_dirs(self.testrunsubdirs) |
| 141 | + self._ln_schema_files(self.openldap_schema_files, self.SCHEMADIR) |
136 | 142 |
|
137 | 143 | def _cleanup_rundir(self): |
138 | 144 | """ |
@@ -183,6 +189,25 @@ def _gen_config(self): |
183 | 189 | } |
184 | 190 | return self.slapd_conf_template % config_dict |
185 | 191 |
|
| 192 | + def _create_sub_dirs(self, dir_names): |
| 193 | + """ |
| 194 | + create sub-directories beneath self.testrundir |
| 195 | + """ |
| 196 | + for dname in dir_names: |
| 197 | + dir_name = os.path.join(self.testrundir, dname) |
| 198 | + self._log.debug('Create directory %s', dir_name) |
| 199 | + os.mkdir(dir_name) |
| 200 | + |
| 201 | + def _ln_schema_files(self, file_names, source_dir): |
| 202 | + """ |
| 203 | + write symbolic links to original schema files |
| 204 | + """ |
| 205 | + for fname in file_names: |
| 206 | + ln_source = os.path.join(source_dir, fname) |
| 207 | + ln_target = os.path.join(self._schema_prefix, fname) |
| 208 | + self._log.debug('Create symlink %s -> %s', ln_source, ln_target) |
| 209 | + os.symlink(ln_source, ln_target) |
| 210 | + |
186 | 211 | def _write_config(self): |
187 | 212 | """Writes the slapd.conf file out, and returns the path to it.""" |
188 | 213 | self._log.debug('Writing config to %s', self._slapd_conf) |
|
0 commit comments