[Freeipa-devel] [PATCH] 0056 Framework for admin/install tools, with ipa-ldap-updater

Petr Viktorin pviktori at redhat.com
Mon Jun 4 14:56:11 UTC 2012


Currently, FreeIPA's install/admin scripts are long pieces of code
that aren't very reusable, importable, or testable.
They have been extended over time with features such as logging and
error handling, but since each tool was extended individually, there
is much inconsistency and code duplication.
This patch starts a framework which the admin tools can use, and
converts ipa-ldap-updater to use the framework.

In an earlier patch I found that improving a particular functionality in 
all the commands is not workable, so I want to tackle this one tool at a 
time.
I'm starting with ipa-ldap-updater, because it's pretty small, doesn't 
use DNs (I don't want conflicts with John's work), and has the 
interesting --upgrade option.


The framework does these tasks:
- Parse options
- Select tool to run (see below)
- Validate options
- Set up logging
- Run the tool code
- Handle any errors
- Log success/failure

The base class has some defaults for these that the tools can 
extend/override.


To handle the case where one script does two different things 
(ipa-ldap-updater with/without --upgrade, or ipa-server-install 
with/without --uninstall), I want to split the tool in two classes 
rather than have repeated ifs in the code.
This meant that option parsing (and initializing the parser) has to be 
done before creating an instance of the tool. I use a factory classmethod.


I put the admintool base class in ipapython/ as it should be useful for 
ipa-client-install as well.



First part of the work for:
https://fedorahosted.org/freeipa/ticket/2652

-- 
Petr³
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-pviktori-0056-Framework-for-admin-install-tools-with-ipa-ldap-upda.patch
Type: text/x-patch
Size: 28953 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20120604/9fc53690/attachment.bin>


More information about the Freeipa-devel mailing list