#4052 Refactor ipapython.platform
Closed: Fixed None Opened 9 years ago by tbabej.

Currently, adding any platform file implementation involves including unnecessary boilerplate code. Making things more simple here will make maintenance of platform files easier as the number of supported platforms grows.

Proposed changes:

  • Move ipapython/platform to a separate python module ipaplatform
  • Create a global base platform file that contains default empty implementations (and therefore defines platform API)
  • Each platform file only overrides the specific functions, and imports the rest either from platform-specific base (e.g. fedora-base, rhel-base) or global base (for empty implementations)
  • Instead of defining a services.py.in file that needs to be processed to generate service.py during the build, place a symlink to the platform file
  • Each platform should define paths.py file containing filepaths

This is something we discussed today. The biggest problem I see with current platform files is that it is difficult to extend them (adding one more platform-item to the platform) and every new platform carry quite a lot of cruft from previous platforms. It seems quite error prone to me.

When I am creating a, say fedora20 platform which differs just in one call compared to previous Fedoras, I should be able to have a quite small platform file like that:

from some.global.fedora.platform.file import *

def fedora20_specific_task:
    pass

First part pushed to master. Some code documentation still pending.

  • 1fc7b04 ipaplatform: Create separate module for platform files
  • 0b97400 ipaplatform: Move service base platfrom related functionality to ipaplatform/base/service.py
  • 1d0623c ipaplatform: Move default implementations of tasks from service.py.in
  • 3fcaf81 ipaplatform: Create default implementations for tasks that were missing them
  • c368aae ipaplatform: Add base fedora platform module
  • c465eb8 ipaplatform: Moved Fedora 16 service implementations and refactored them as base Fedora module service implementations
  • 6a4cd8a ipaplatform: Move restore_context and check_selinux_status implementations to base fedora platform tasks
  • 5f31f2d ipaplatform: Do not require custom Authconfig implementations from platform modules
  • 3edfabb ipaplatform: Remove legacy redhat platform module
  • a7c2327 ipaplatform: Move Fedora-specific implementations of tasks to fedora base platform file
  • 926f864 ipaplatform: Change platform dependant code in freeipa to use ipaplatform tasks
  • 49fcd42 ipaplatform: Change service code in freeipa to use ipaplatform services
  • c011bcc ipaplatform: Change paths dependant on ipaservices to use ipaplatform.paths
  • c7edd7b ipaplatform: Remove redundant imports of ipaservices
  • 4d2ef43 ipaplatform: Move all filesystem paths to ipaplatform.paths module
  • a9a4bc0 ipaplatform: Remove remnants of the ipapython/platform
  • 3bb9e1b ipaplatform: Change makefiles to accomodate for new platform package
  • 6906eed ipaplatform: Let fedora path module use PathNamespace class
  • c8aa008 ipaplatform: Link to platform module during build time
  • f0d0640 ipaplatform: Pylint fixes
  • 8a5e2a8 ipaplatform: Contain all the tasks in the TaskNamespace
  • 3b4ab8b ipaplatform: Move hardcoded paths from Fedora platform files to path namespace
  • d868fc5 Fix self argument in tasks

second part:

  • e099ad4 ipaplatform: Document the platform tasks API
  • 2a3c746 ipaplatform: Drop the base authconfig class
  • 6973873 ipaplatform: Fix build warnings
  • c8511d3 ipaplatform: Fix misspelled path constant

master:

  • e5e42fc ipaplatform: Move paths from installers to paths module

A minor task to clean up is tracked here: https://fedorahosted.org/freeipa/ticket/4399

Some hardcoded paths still remain, when they're part of larger strings. These will need to be found and fixed individually. I'm keeping the ticket open for that.

I would rather close this ticket as the platform is ready and the framework is there. I would like to see contributions from people working on other platforms for these other paths or at least an interest that this is blocking them.

Thanks for the effort!

Metadata Update from @tbabej:
- Issue assigned to tbabej
- Issue set to the milestone: FreeIPA 4.0 Backlog

6 years ago

Login to comment on this ticket.

Metadata