From f7e6102ebfd6e2a87bd584fc2fbbcb9945ac7753 Mon Sep 17 00:00:00 2001 From: Martin Babinsky Date: Fri, 13 Feb 2015 17:53:27 +0100 Subject: [PATCH] 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 --- ipalib/plugins/migration.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py index cd1fa73f8..d9406907b 100644 --- a/ipalib/plugins/migration.py +++ b/ipalib/plugins/migration.py @@ -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)