wiki:RefactorClient

Version 27 (modified by desai, 15 years ago) (diff)

--

Bcfg2 Client Code Refactoring

This branch is for work in decomposing the platform-specific client modules into service/packaging system-specific modules; the platform-specific modules will then just import the service/packaging system-specific modules they require (e.g. Redhat.py would import rpm.py and chkconfig.py, all the platforms will import encap.py, etc.)

A mailing list thread with more discussion of this is here:

Ticket #73 describes some aspects of this issue.

NLD's 4-Step Plan

  1. create classes in Bcfg2.Client.Tools that defines an API for all tools (Implemented as Bcfg2.Client.Tools.Tool, Bcfg2.Client.Tools.PkgTool?, and Bcfg2.Client.SvcTool?). All Tools will subclass one of these (Bcfg2.Client.Tools.RPM, Bcfg2.Client.Tools.SMF, etc) [DONE]
  2. build a set of error types that can be raised during tool instantiation and operation [DONE]
  3. Implement a tool class for each underlying tool. (see table below for status)
  4. modify the Bcfg2.Client.Frame code to figure out what methods to call tools for entry verification, installation and removal.
  5. is things like schema updates and metadata code updates

Implementation Status

This work is happening at:

https://svn.mcs.anl.gov/repos/bcfg/branches/refactor/client

Bcfg2.Client.Frame is nearly completely finished. (It mainly redirects calls to underlying tools.)

ToolStatusWho
RPM doneNLD
POSIXdoneNLD
EncapdoneDC
SYSVdoneNLD
Pkg-get (Blastwave)doneNLD
APTdoneNLD
ChkConfig?doneNLD
Update-RC.d
SMF
LaunchdTL
Emerge

(V == Verify/I == Install/E == Extra detection/R == Removal)

Design Notes

Bcfg2.Client.Frame redirects calls to underlying tools. Its methods are:

  • Inventory - Compare client state to configuration specification
  • Install - Install wrong entries (sparsely, if specified)
  • FindExtra - Locate extra entries using tool-specific heuristics
  • Query - get user input of which entries should be modified
  • Remove - remove specified extra entries

Tool methods:

  • Verify<entry.tag> - verify entry state. Must return True/False?
  • Install<entry.tag> - install entry. Must return True/False?
  • Install (optional) - bulk install method for entries
  • FindExtra - locate extra entries

Writing a Client Tool Module

  1. Add a new file in src/lib/Client/Tools/
  2. Add an entry for this file in src/lib/Client/Tools/__init__.py
  3. Add a class in this file, with the same name as the file, that subclasses Bcfg2.Client.Tools.Tool (Bcfg2.Client.Tools.PkgTool for packaging systems)
  4. Add a method Verify<entry.tag> that returns true or false, based on client state (Mark Verify as done)
  5. If Add a method Install<entry.tag> that returns true or false. (For non package tools)
  6. Add a Remove method that removes entries based on self.setup (Mark Removal as done)
  7. Add a FindExtra method that locates entries not included in the configuration (Mark Extra Detection as done) (optional; this may not be possible depending on the tool)

For packaging tools, subclass Bcfg2.Client.Tools.PkgTool and define pkgtype and pkgtool. See the RPM module for an example.