summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2015-04-29 08:15:57 +0200
committerTomas Babej <tbabej@redhat.com>2015-07-02 13:23:21 +0200
commite7d7f01d5ffbb8d3c5d5e882ca19b7b9fe96aa7c (patch)
tree2f9caa8be47134e667cff4e38e8df7198bb43ca0
parent2104e07fa82dc599fe81cea822dfa8b060cc91cc (diff)
downloadfreeipa-e7d7f01d5ffbb8d3c5d5e882ca19b7b9fe96aa7c.zip
freeipa-e7d7f01d5ffbb8d3c5d5e882ca19b7b9fe96aa7c.tar.gz
freeipa-e7d7f01d5ffbb8d3c5d5e882ca19b7b9fe96aa7c.tar.xz
migrate-winsync: Add option validation and handling
https://fedorahosted.org/freeipa/ticket/4524 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
-rw-r--r--ipaserver/winsync_migrate/base.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/ipaserver/winsync_migrate/base.py b/ipaserver/winsync_migrate/base.py
index 4d2ef4d..60b75b5 100644
--- a/ipaserver/winsync_migrate/base.py
+++ b/ipaserver/winsync_migrate/base.py
@@ -46,6 +46,50 @@ class MigrateWinsync(admintool.AdminTool):
"For more information, see `man ipa-migrate-winsync`."
)
+ @classmethod
+ def add_options(cls, parser):
+ """
+ Adds command line options to the tool.
+ """
+ super(MigrateWinsync, cls).add_options(parser)
+
+ parser.add_option(
+ "--realm",
+ dest="realm",
+ help="The AD realm the winsynced users belong to")
+ parser.add_option(
+ "-U", "--unattended",
+ dest="interactive",
+ action="store_false",
+ default=True,
+ help="Never prompt for user input")
+
+ def validate_options(self):
+ """
+ Validates the options passed by the user:
+ - Checks that trust has been established with
+ the realm passed via --realm option
+ """
+
+ super(MigrateWinsync, self).validate_options()
+
+ if self.options.realm is None:
+ raise admintool.ScriptError(
+ "AD realm the winsynced users belong to needs to be "
+ "specified.")
+ else:
+ try:
+ api.Command['trust_show'](unicode(self.options.realm))
+ except errors.NotFound:
+ raise admintool.ScriptError(
+ "Trust with the given realm %s could not be found. "
+ "Please establish the trust prior to migration."
+ % self.options.realm)
+ except Exception as e:
+ raise admintool.ScriptError(
+ "An error occured during detection of the established "
+ "trust with %s: %s" % (self.options.realm, str(e)))
+
def create_id_user_override(self, entry):
"""
Creates ID override corresponding to this user entry.