Skip to content

Commit a28837d

Browse files
author
stroeder
committed
added new SlapdObject methods _ln_schema_files() and _create_sub_dirs()
1 parent ecac3db commit a28837d

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

CHANGES

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Released 2.4.42 2017-08-xx
44
Changes since 2.4.41:
55

66
Lib/
7-
*
7+
* added new SlapdObject methods _ln_schema_files() and
8+
_create_sub_dirs()
89

910
----------------------------------------------------------------
1011
Released 2.4.41 2017-07-12
@@ -1468,4 +1469,4 @@ Released 2.0.0pre02 2002-02-01
14681469
----------------------------------------------------------------
14691470
Released 1.10alpha3 2000-09-19
14701471

1471-
$Id: CHANGES,v 1.453 2017/08/03 17:24:43 stroeder Exp $
1472+
$Id: CHANGES,v 1.454 2017/08/03 17:26:59 stroeder Exp $

Lib/slapdtest.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
55
See http://www.python-ldap.org/ for details.
66
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 $
88
99
Python compability note:
1010
This module only works with Python 2.7.x since
1111
"""
1212

13-
__version__ = '2.4.41'
13+
__version__ = '2.4.42'
1414

1515
import os
1616
import socket
@@ -99,6 +99,10 @@ class SlapdObject(object):
9999
# use SASL/EXTERNAL via LDAPI when invoking OpenLDAP CLI tools
100100
cli_sasl_external = True
101101
local_host = '127.0.0.1'
102+
testrunsubdirs = (())
103+
openldap_schema_files = (
104+
'core.schema',
105+
)
102106

103107
TMPDIR = os.environ.get('TMP', os.getcwd())
104108
SBINDIR = os.environ.get('SBIN', '/usr/sbin')
@@ -133,6 +137,8 @@ def _setup_rundir(self):
133137
"""
134138
os.mkdir(self.testrundir)
135139
os.mkdir(self._db_directory)
140+
self._create_sub_dirs(self.testrunsubdirs)
141+
self._ln_schema_files(self.openldap_schema_files, self.SCHEMADIR)
136142

137143
def _cleanup_rundir(self):
138144
"""
@@ -183,6 +189,25 @@ def _gen_config(self):
183189
}
184190
return self.slapd_conf_template % config_dict
185191

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+
186211
def _write_config(self):
187212
"""Writes the slapd.conf file out, and returns the path to it."""
188213
self._log.debug('Writing config to %s', self._slapd_conf)

0 commit comments

Comments
 (0)