From c298560a1e733908148224b0fef6cc6042cbbe82 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 27 Sep 2010 13:50:54 -0400 Subject: Handle an empty base_dn and no cn=ipaconfig in the ldap2 backend, fix migration. We lacked good error messages if the user/group container you used doesn't exist. Add a --continue option so things can continue if you use a bad user/group container. This has the side-effect of letting you migrate just users or groups by using a bad container for the one you don't want. Fix a Gettext() error when displaying the migrated password message. ticket 289 --- ipalib/plugins/migration.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'ipalib/plugins/migration.py') diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py index a2773efb..39f09eed 100644 --- a/ipalib/plugins/migration.py +++ b/ipalib/plugins/migration.py @@ -28,7 +28,7 @@ import logging import re from ipalib import api, errors, output, uuid -from ipalib import Command, List, Password, Str +from ipalib import Command, List, Password, Str, Flag from ipalib.cli import to_cli if api.env.in_server and api.env.context in ['lite', 'server']: try: @@ -196,6 +196,10 @@ class migrate_ds(Command): default=u'ou=groups', autofill=True, ), + Flag('continue?', + doc=_('Continous operation mode. Errors are reported but the process continues'), + default=False, + ), ) has_output = ( @@ -283,10 +287,17 @@ can use their Kerberos accounts.''') failed[ldap_obj_name] = {} # FIXME: with limits set, we get a strange 'Success' exception - (entries, truncated) = ds_ldap.find_entries( - search_filter, ['*'], search_base, ds_ldap.SCOPE_ONELEVEL#, - #time_limit=0, size_limit=0 - ) + try: + (entries, truncated) = ds_ldap.find_entries( + search_filter, ['*'], search_base, ds_ldap.SCOPE_ONELEVEL#, + #time_limit=0, size_limit=0 + ) + except errors.NotFound: + if not options.get('continue',False): + raise errors.NotFound(reason=_('Container for %(container)s not found' % {'container':ldap_obj_name})) + else: + truncated = False + entries = [] if truncated: self.log.error( '%s: %s' % ( @@ -380,6 +391,6 @@ can use their Kerberos accounts.''') one_value_per_line=True, ) textui.print_plain('-' * len(self.name)) - textui.print_plain(self.pwd_migration_msg) + textui.print_plain(unicode(self.pwd_migration_msg)) api.register(migrate_ds) -- cgit