From cf61e2ad94f0e2f822f203291e5adc5882f55e77 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Jul 02 2015 11:23:21 +0000 Subject: winsync-migrate: Move the api initalization and LDAP connection to the main method https://fedorahosted.org/freeipa/ticket/4524 Reviewed-By: Martin Babinsky --- diff --git a/ipaserver/winsync_migrate/base.py b/ipaserver/winsync_migrate/base.py index 60b75b5..60c2cad 100644 --- a/ipaserver/winsync_migrate/base.py +++ b/ipaserver/winsync_migrate/base.py @@ -134,8 +134,12 @@ class MigrateWinsync(admintool.AdminTool): return entries - def run(self): - super(MigrateWinsync, self).run() + @classmethod + def main(cls, argv): + """ + Sets up API and LDAP connection for the tool, then runs the rest of + the plumbing. + """ # Finalize API api.bootstrap(in_server=True, context='server') @@ -146,7 +150,7 @@ class MigrateWinsync(admintool.AdminTool): ctx = krbV.default_context() ccache = ctx.default_ccache() api.Backend.ldap2.connect(ccache) - self.ldap = api.Backend.ldap2 + cls.ldap = api.Backend.ldap2 except krbV.Krb5Error, e: sys.exit("Must have Kerberos credentials to migrate Winsync users.") except errors.ACIError, e: @@ -154,6 +158,11 @@ class MigrateWinsync(admintool.AdminTool): except errors.DatabaseError, e: sys.exit("Cannot connect to the LDAP database. Please check if IPA is running.") + super(MigrateWinsync, cls).main(argv) + + def run(self): + super(MigrateWinsync, self).run() + # Create ID overrides replacing the user winsync entries entries = self.find_winsync_users() for entry in entries: