diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-09-27 13:50:54 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-09-28 13:39:28 -0400 |
commit | c298560a1e733908148224b0fef6cc6042cbbe82 (patch) | |
tree | 2947a48243f84918c8e47c06a325a7f732b55119 /ipalib/plugins/migration.py | |
parent | 38b8532696b4c969e437452386b7019d1266a69c (diff) | |
download | freeipa-c298560a1e733908148224b0fef6cc6042cbbe82.tar.gz freeipa-c298560a1e733908148224b0fef6cc6042cbbe82.tar.xz freeipa-c298560a1e733908148224b0fef6cc6042cbbe82.zip |
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
Diffstat (limited to 'ipalib/plugins/migration.py')
-rw-r--r-- | ipalib/plugins/migration.py | 23 |
1 files changed, 17 insertions, 6 deletions
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) |