# rom ..config.ldap import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS
from ..config.ldap import DEFAULT_TIMEOUT
-__version__ = '0.8.1'
+__version__ = '0.8.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
}
help_default_inst = _(
- "If not given, then the instance {!r} will be used.").format('default')
+ "If not given, then the instance {!r} will be used.").format('default')
help_single = _(
"The LDAP instance (LDAP cluster) from configuration, "
"then all found LDAP instances except {default!r} are used. "
"It is alo possible to give the value {val_list!r}, then all configured "
"LDAP instances are shown, and the application is exiting.").format(
- val_all='all', val_list='list', default='default')
+ val_all='all', val_list='list', default='default')
if self.use_multiple_ldap_connections:
if self.apply_default_ldap_instance_if_not_given:
msg = _("Used filter:") + ' ' + format_list(show_filter)
LOG.debug(msg)
- instances = []
+ filtered_instances = []
for inst in self.cfg.ldap_connection.keys():
if inst == 'default':
continue
if has_sync_source:
if instance.sync_source is None:
continue
- instances.append(inst.lower())
-
- if len(self.ldap_instances) == 1 and self.ldap_instances[0].lower() == 'all':
- self.ldap_instances = instances
+ filtered_instances.append(inst.lower())
- else:
+ self._validate_given_instances(filtered_instances)
- if 'default' in self.cfg.ldap_connection:
- if self.apply_default_ldap_instance_if_not_given:
- instances.insert(0, 'default')
+ if self.verbose > 1:
+ LOG.debug(_("LDAP instances to use:") + ' ' + pp(self.ldap_instances))
- all_ok = True
- for given_inst in self.ldap_instances:
- if given_inst not in instances:
- msg = _(
- "LDAP instance {!r} not found in configuration or is not usable.").format(
- given_inst)
- LOG.error(msg)
- all_ok = False
+ # -------------------------------------------------------------------------
+ def _validate_given_instances(self, filtered_instances):
- if not all_ok:
- self.exit(1)
+ if len(self.ldap_instances) == 1 and self.ldap_instances[0].lower() == 'all':
+ self.ldap_instances = filtered_instances
+ return
- if self.verbose > 1:
- LOG.debug(_("LDAP instances to use:") + ' ' + pp(self.ldap_instances))
+ if 'default' in self.cfg.ldap_connection:
+ if self.apply_default_ldap_instance_if_not_given:
+ filtered_instances.insert(0, 'default')
+
+ all_ok = True
+ for given_inst in self.ldap_instances:
+ if given_inst not in filtered_instances:
+ msg = _("LDAP instance {!r} not found in configuration or is not usable.").format(
+ given_inst)
+ LOG.error(msg)
+ all_ok = False
+
+ if not all_ok:
+ self.exit(1)
# -------------------------------------------------------------------------
def _init_default_connection(self):