from .ldap import BaseLdapApplication
from ..xlate import XLATOR
-__version__ = '0.9.5'
+__version__ = '0.9.6'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
inst = self.ldap_instances[0]
nr_aliases = len(self.aliases_to_remove)
+ i = 0
if not nr_aliases:
msg = _('No aliases found to remove in LDAP.')
time.sleep(self.wait_interval * 10)
return
- for dn in self.aliases_to_remove:
- self.delete_entry(inst, dn)
- if self.wait_interval:
- time.sleep(self.wait_interval)
+ try:
+ for dn in self.aliases_to_remove:
+ self.delete_entry(inst, dn)
+ i += 1
+ 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)
+ finally:
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry removed in LDAP.', '{} alias entries removed in LDAP.',
+ i).format(i)
+ LOG.info(msg)
+ if self.wait_interval:
+ time.sleep(self.wait_interval * 10)
# -------------------------------------------------------------------------
def add_failing_ldap_entries(self):
inst = self.ldap_instances[0]
nr_aliases = len(self.aliases_to_create)
+ i = 0
if not nr_aliases:
msg = _('No aliases found to create in LDAP.')
time.sleep(self.wait_interval * 10)
return
- for cn in self.aliases_to_create:
- dn = 'cn=' + cn + ',' + self.barracuda_base_dn
- (oclasses, attributes) = self._create_ldap_entry_for_create(cn)
- LOG.info(_('Creating LDAP alias {a!r} => {dn!r}.').format(a=cn, dn=dn))
- self.add_entry(inst, dn, oclasses, attributes)
+ try:
+ for cn in self.aliases_to_create:
+ dn = 'cn=' + cn + ',' + self.barracuda_base_dn
+ (oclasses, attributes) = self._create_ldap_entry_for_create(cn)
+ LOG.info(_('Creating LDAP alias {a!r} => {dn!r}.').format(a=cn, dn=dn))
+ self.add_entry(inst, dn, oclasses, attributes)
+ i += 1
+ if self.wait_interval:
+ time.sleep(self.wait_interval)
+
+ finally:
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry created in LDAP.', '{} alias entries created in LDAP.',
+ i).format(i)
+ LOG.info(msg)
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)
+ time.sleep(self.wait_interval * 10)
# -------------------------------------------------------------------------
def modify_existing_entries(self):
inst = self.ldap_instances[0]
nr_aliases = len(self.aliases_to_modify.keys())
+ i = 0
if not nr_aliases:
msg = _('No aliases found to mofify in LDAP.')
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)
+ try:
+ 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)
+ i += 1
+ if self.wait_interval:
+ time.sleep(self.wait_interval)
+
+ finally:
+ self.empty_line()
+ msg = ngettext(
+ 'One alias entry modified in LDAP.', '{} alias entries modified in LDAP.',
+ i).format(i)
+ LOG.info(msg)
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)
+ time.sleep(self.wait_interval * 10)
# -------------------------------------------------------------------------
def _run(self):