[Freeipa-devel] [WIP] ipapython/iputil.py refactoring for better cross-platform support

Alexander Bokovoy abokovoy at redhat.com
Wed Jul 20 17:30:21 UTC 2011


Hi,

On 19.07.2011 16:36, Alexander Bokovoy wrote:
>> I believe that nss-pam-ldapd uses a different configuration file than
>> nss_ldap, I think I'd rather use the existence of that to determine what
>> is being used. Calling out to rpm seems heavy-weight.
> In continuation of the same story, ticket 1368 asks for propagating
> hostname into static configuration (/etc/sysconfig/network, HOSTNAME
> variable on Red Hat systems). This is an example of system-specific
> common code where we want to ensure configuration is made and backed up
> but we don't care what is configuration's location and format. I.e.
> perfect example to write platform-specific support.
> 
> I'm going to rework ipautil into providing common functions and loading
> platform-specific ones from separate files so that we can have Red Hat
> or Fedora (or LSB) platforms, Debian-based platforms and so on. Remeber,
> this is for ipa-client-install so some flexibility is welcomed here.
> 
> I'll try to avoid using package management tools in such
> platform-specific code as much as possible also to avoid lock conflicts
> (if something is being installed in background you might get locked when
> asking a package database).
> 
> We don't need to do platform detection at runtime as that is could be
> deferred to package maintainers. After all, IPA most likely will be
> packaged and ipa-client-install will come from such a package. Thus,
> providing proper ipautil-system.py file can be done as packaging effort.

Attached is a first cut for the refactoring. It introduces
ipapython.services which is a container for service- and
platform-specific methods and classes that would require different
behavior depending on a distribution in question.

I moved existing code to ipapython/platform/redhat.py.
ipapython/services.py is auto-generated and basically is one-liner:
=====
from ipapython.platform.<platform> import *
=====

Actual <platform> value is substituted using top-level Makefile's
SUPPORTED_PLAFTORM= variable (defaults to 'redhat', can be redefined
without modifying Makefile, in package building scripts, for example)
and then ipapython/services.py is generated from ipapython/services.py.in

I have converted all users of ipapython.iputil to a new interface but
haven't really tested the code yet apart from make dist and make-lint.

As it is work in progress, all comments and suggestions are welcome!
-- 
/ Alexander Bokovoy
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: freeipa-abbra-0006-iputil-refactor.patch
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20110720/26d3d74f/attachment.ksh>


More information about the Freeipa-devel mailing list