from .ldap import BaseLdapApplication
from ..xlate import XLATOR
-__version__ = '0.9.4'
+__version__ = '0.9.5'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
LOG.info(_('Removing all no more used alias entries ...'))
inst = self.ldap_instances[0]
- if not len(self.aliases_to_remove):
+ nr_aliases = len(self.aliases_to_remove)
+
+ if not nr_aliases:
msg = _('No aliases found to remove in LDAP.')
LOG.info(msg)
if self.wait_interval:
if self.wait_interval:
time.sleep(self.wait_interval)
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry removed in LDAP.', '{} alias entries removed in LDAP.',
+ nr_aliases).format(nr_aliases)
+ LOG.info(msg)
+ if self.wait_interval:
+ time.sleep(self.wait_interval * 10)
+
# -------------------------------------------------------------------------
def add_failing_ldap_entries(self):
"""Create failing LDAP entries."""
LOG.info(_('Adding failing LDAP aliases ...'))
inst = self.ldap_instances[0]
- if not len(self.aliases_to_create):
+ nr_aliases = len(self.aliases_to_create)
+
+ if not nr_aliases:
msg = _('No aliases found to create in LDAP.')
LOG.info(msg)
if self.wait_interval:
if self.wait_interval:
time.sleep(self.wait_interval)
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry created in LDAP.', '{} alias entries created in LDAP.',
+ nr_aliases).format(nr_aliases)
+ LOG.info(msg)
+ if self.wait_interval:
+ time.sleep(self.wait_interval * 10)
+
+ # -------------------------------------------------------------------------
+ def modify_existing_entries(self):
+ """Modify existing LDAP entries below the Barracuda container."""
+ self.empty_line()
+ LOG.info(_('Modifying existing alieas entries ...'))
+ inst = self.ldap_instances[0]
+
+ nr_aliases = len(self.aliases_to_modify.keys())
+
+ if not nr_aliases:
+ msg = _('No aliases found to mofify in LDAP.')
+ LOG.info(msg)
+ if self.wait_interval:
+ time.sleep(self.wait_interval * 10)
+ return
+
+ for dn in sorted(self.aliases_to_modify.keys(), key=cmp_to_key(self.compare_ldap_dns)):
+ modify_data = self.aliases_to_modify[dn]
+ LOG.info(_('Modifying LDAP alias {!r} ...').format(dn))
+ self.modify_entry(inst, dn, modify_data)
+ if self.wait_interval:
+ time.sleep(self.wait_interval)
+
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry modified in LDAP.', '{} alias entries modified in LDAP.',
+ nr_aliases).format(nr_aliases)
+ LOG.info(msg)
+ if self.wait_interval:
+ time.sleep(self.wait_interval * 10)
+
# -------------------------------------------------------------------------
def _run(self):
self.eval_diffs()
self.remove_old_alias_entries()
self.add_failing_ldap_entries()
+ self.modify_existing_entries()
+
+ self.empty_line()
+ LOG.info(_('Finished.'))
+ self.empty_line()
# =============================================================================