Skip to content

Commit

Permalink
added new SlapdObject methods _ln_schema_files() and _create_sub_dirs()
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Aug 3, 2017
1 parent ecac3db commit a28837d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $
29 changes: 27 additions & 2 deletions Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a28837d

Please sign in to comment.