sampledoc

Writing A Client Tool Driver

This page describes the step-by-step process of writing a client tool driver for a configuration element type. The included example describes an existing driver, and the process that was used to create it.

  1. Pick a name for the driver. In this case, we picked the name RPM.

  2. Create a file in src/lib/Bcfg2/Client/Tools with the same name (RPM.py)

  3. Create a class in this file with the same name (class RPM)

    • If it handles Package entries, subclass Bcfg2.Client.Tools.PkgTool
    • If it handles Service entries, subclass Bcfg2.Client.Tools.SvcTool
    • Otherwise, subclass Bcfg2.Client.Tools.Tool.
  4. Add any required executable programs to Bcfg2.Client.Tools.Tool.__execs__

  5. Set Bcfg2.Client.Tools.Tool.__handles__ to a list of (<tag>, <type>) tuples. This determines which entries the Tool module can be used on. In this case, we set __handles__ = [('Package', 'rpm')].

  6. Add verification support by defining a method named Verify<tag>. See Bcfg2.Client.Tools.Tool.Inventory() for details. This method should return True/False depending on current entry installation status. In the failure path, the current state of failing entry attributes should be set in the entry, to aid in auditing. (For example, if a file should be mode 644, and is currently mode 600, then set attribute current_mode=‘600’ in the input entry)

  7. Add installation support by defining a method named Install<tag. See Bcfg2.Client.Tools.Tool.Install() for details. This method should return True/False depending on the results of the installation process.

    If you are writing a tool to handle Package entries, PkgTool class has a generic mechanism for performing all-at-once installations, followed, in the case of failures, by single installations. See Bcfg2.Client.Tools.PkgTool.Install() for details.

  8. Optionally, add support for removing extra entries by defining a Bcfg2.Client.Tools.Tool.Remove() method.

  9. Optionally, add a Bcfg2.Client.Tools.Tool.FindExtra() method that locates entries not included in the configuration.

  10. Package drivers require a Bcfg2.Client.Tools.PkgTool.RefreshPackages() method that updates the internal representation of the package database.

Client Tool API

Base Classes

Helper Classes

Table Of Contents

Previous topic

Cfg Handler Development

Next topic

Python Compatibility

This Page