wiki:RefactorClient

Version 42 (modified by desai, 16 years ago) (diff)

--

Bcfg2 Client Code Refactoring

This page reflects a completed project. It has been merged into trunk and was the basis for the 0.8.5 release.

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 5-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 was happening at:

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

It has since been completed and merged into trunk.

Bcfg2.Client.Frame is completely finished. It redirects calls to lower-level tool modules. It also provides a unified view across all tools.

ToolStatusWhoTested?
RPMdoneNLD Yes
POSIXdoneNLDYes
EncapdoneDCNo
SYSVdoneNLDYes
Pkg-get (Blastwave)doneNLDNo
APTdoneNLDYes
ChkConfig?doneNLDYes
SMFdoneNLDYes
PostInstall?doneNLDYes
DebInit?doneNLDYes
launchddoneJHYes

All currently supported tools are now implemented. For tools which may be added in the future, see FeatureClient?.

Test Plan

  1. Get verification working (done)
  2. Get stats gathering and upload working (done)
  3. Find and complain about unhandled config entries (done)
  4. Verify results against the old client (done on debian, must be done for redhat and solaris)
  5. Build small test sets to test install set

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

See WritingClientToolDrivers for details.