migrate-ds: exit with error message if no users/groups to migrate are found

'ipa migrate-ds' will now exit with error message if no suitable users/groups
are found on LDAP server during migration.

https://fedorahosted.org/freeipa/ticket/4846

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Martin Babinsky 2015-02-13 17:53:27 +01:00 committed by Martin Kosek
parent 373a04870d
commit 06376a48b2

View File

@ -841,6 +841,12 @@ can use their Kerberos accounts.''')
api.log.info("%d %ss migrated. %s elapsed." % (migrate_cnt, ldap_obj_name, total_dur))
api.log.debug("%d %ss migrated, duration: %s (total %s)" % (migrate_cnt, ldap_obj_name, d, total_dur))
# if no users/groups were found (all lists in 'migrated' are empty),
# we raise an error that there is nothing to migrate
if not any(migrated.values()):
raise errors.NotFound(
reason=_("Found no users/groups to migrate "
"from '%(ds_ldap)s'.") % dict(ds_ldap=ds_ldap))
_update_default_group(ldap, pkey, config, context, True)
return (migrated, failed)