Package CedarBackup2 :: Module config
[show private | hide private]
[frames | no frames]

Module CedarBackup2.config

Provides configuration-related objects.

Summary

Cedar Backup stores all of its configuration in an XML document typically called cback.conf. The standard location for this document is in /etc, but users can specify a different location if they want to.

The Config class is a Python object representation of a Cedar Backup XML configuration file. The representation is two-way: XML data can be used to create a Config object, and then changes to the object can be propogated back to disk. A Config object can even be used to create a configuration file from scratch programmatically.

The Config class is intended to be the only Python-language interface to Cedar Backup configuration on disk. Cedar Backup will use the class as its internal representation of configuration, and applications external to Cedar Backup itself (such as a hypothetical third-party configuration tool written in Python or a third party extension module) should also use the class when they need to read and write configuration files.

Backwards Compatibility

The configuration file format has changed between Cedar Backup 1.x and Cedar Backup 2.x. Any Cedar Backup 1.x configuration file is also a valid Cedar Backup 2.x configuration file. However, it doesn't work to go the other direction, as the 2.x configuration files may contain additional fields that are not accepted by older versions of the software.

XML Configuration Structure

A Config object can either be created "empty", or can be created based on XML input (either in the form of a string or read in from a file on disk). Generally speaking, the XML input must result in a Config object which passes the validations laid out below in the Validation section.

An XML configuration file is composed of seven sections:

Each section is represented by an class in this module, and then the overall Config class is a composition of the various other classes.

Any configuration section that is missing in the XML document (or has not been filled into an "empty" document) will just be set to None in the object representation. The same goes for individual fields within each configuration section. Keep in mind that the document might not be completely valid if some sections or fields aren't filled in - but that won't matter until validation takes place (see the Validation section below).

Unicode vs. String Data

By default, all string data that comes out of XML documents in Python is unicode data (i.e. u"whatever"). This is fine for many things, but when it comes to filesystem paths, it can cause us some problems. We really want strings to be encoded in the filesystem encoding rather than being unicode. So, most elements in configuration which represent filesystem paths are coverted to plain strings using util.encodePath. The main exception is the various absoluteExcludePath and relativeExcludePath lists. These are not converted, because they are generally only used for filtering, not for filesystem operations.

Validation

There are two main levels of validation in the Config class and its children. The first is field-level validation. Field-level validation comes into play when a given field in an object is assigned to or updated. We use Python's property functionality to enforce specific validations on field values, and in some places we even use customized list classes to enforce validations on list members. You should expect to catch a ValueError exception when making assignments to configuration class fields.

The second level of validation is post-completion validation. Certain validations don't make sense until a document is fully "complete". We don't want these validations to apply all of the time, because it would make building up a document from scratch a real pain. For instance, we might have to do things in the right order to keep from throwing exceptions, etc.

All of these post-completion validations are encapsulated in the Config.validate method. This method can be called at any time by a client, and will always be called immediately after creating a Config object from XML data and before exporting a Config object to XML. This way, we get decent ease-of-use but we also don't accept or emit invalid configuration files.

The Config.validate implementation actually takes two passes to completely validate a configuration document. The first pass at validation is to ensure that the proper sections are filled into the document. There are default requirements, but the caller has the opportunity to override these defaults.

The second pass at validation ensures that any filled-in section contains valid data. Any section which is not set to None is validated according to the rules for that section (see below).

Reference Validations

No validations.

Extensions Validations

The list of actions may be either None or an empty list [] if desired. Each extended action must include a name, a module and a function. Then, an extended action must include either an index or dependency information. Which one is required depends on which order mode is configured.

Options Validations

All fields must be filled in. The rcp command is used as a default value for all remote peers in the staging section. Remote peers can also rely on the backup user as the default remote user name if they choose.

Collect Validations

The target directory must be filled in. The collect mode, archive mode and ignore file are all optional. The list of absolute paths to exclude and patterns to exclude may be either None or an empty list [] if desired.

Each collect directory entry must contain an absolute path to collect, and then must either be able to take collect mode, archive mode and ignore file configuration from the parent CollectConfig object, or must set each value on its own. The list of absolute paths to exclude, relative paths to exclude and patterns to exclude may be either None or an empty list [] if desired. Any list of absolute paths to exclude or patterns to exclude will be combined with the same list in the CollectConfig object to make the complete list for a given directory.

Stage Validations

The target directory must be filled in. There must be at least one peer (remote or local) between the two lists of peers. A list with no entries can be either None or an empty list [] if desired.

Local peers must be completely filled in, including both name and collect directory. Remote peers must also fill in the name and collect directory, but can leave the remote user and rcp command unset. In this case, the remote user is assumed to match the backup user from the options section and rcp command is taken directly from the options section.

Store Validations

The device type and drive speed are optional, and all other values are required (missing booleans will be set to defaults, which is OK).

The image writer functionality in the writer module is supposed to be able to handle a device speed of None. Any caller which needs a "real" (non-None) value for the device type can use DEFAULT_DEVICE_TYPE, which is guaranteed to be sensible.

Purge Validations

The list of purge directories may be either None or an empty list [] if desired. All purge directories must contain a path and a retain days value.

Author: Kenneth J. Pronovici <pronovic@ieee.org>

Classes
ActionDependencies Class representing dependencies associated with an extended action.
ActionHook Class representing a hook associated with an action.
PreActionHook Class representing a pre-action hook associated with an action.
PostActionHook Class representing a pre-action hook associated with an action.
ExtendedAction Class representing an extended action.
CommandOverride Class representing a piece of Cedar Backup command override configuration.
CollectFile Class representing a Cedar Backup collect file.
CollectDir Class representing a Cedar Backup collect directory.
PurgeDir Class representing a Cedar Backup purge directory.
LocalPeer Class representing a Cedar Backup peer.
RemotePeer Class representing a Cedar Backup peer.
ReferenceConfig Class representing a Cedar Backup reference configuration.
ExtensionsConfig Class representing Cedar Backup extensions configuration.
OptionsConfig Class representing a Cedar Backup global options configuration.
CollectConfig Class representing a Cedar Backup collect configuration.
StageConfig Class representing a Cedar Backup stage configuration.
StoreConfig Class representing a Cedar Backup store configuration.
PurgeConfig Class representing a Cedar Backup purge configuration.
Config Class representing a Cedar Backup XML configuration document.
BlankBehavior Class representing optimized store-action media blanking behavior.

Variable Summary
str DEFAULT_DEVICE_TYPE: The default device type.
str DEFAULT_MEDIA_TYPE: The default media type.
list VALID_DEVICE_TYPES: List of valid device types.
list VALID_MEDIA_TYPES: List of valid media types.
list VALID_COLLECT_MODES: List of valid collect modes.
list VALID_ARCHIVE_MODES: List of valid archive modes.
list VALID_ORDER_MODES: List of valid extension order modes.
str ACTION_NAME_REGEX = '^[a-z0-9]*$'
Logger logger = <logging.Logger instance at 0x4030ee0c>
list REWRITABLE_MEDIA_TYPES = ['cdrw-74', 'cdrw-80', 'dvd+rw'...
list VALID_BLANK_MODES = ['daily', 'weekly']
list VALID_CD_MEDIA_TYPES = ['cdr-74', 'cdrw-74', 'cdr-80', '...
list VALID_COMPRESS_MODES: List of valid compress modes.
list VALID_DVD_MEDIA_TYPES = ['dvd+r', 'dvd+rw']

Variable Details

DEFAULT_DEVICE_TYPE

The default device type.
Type:
str
Value:
'cdwriter'                                                             

DEFAULT_MEDIA_TYPE

The default media type.
Type:
str
Value:
'cdrw-74'                                                              

VALID_DEVICE_TYPES

List of valid device types.
Type:
list
Value:
['cdwriter', 'dvdwriter']                                              

VALID_MEDIA_TYPES

List of valid media types.
Type:
list
Value:
['cdr-74', 'cdrw-74', 'cdr-80', 'cdrw-80', 'dvd+r', 'dvd+rw']          

VALID_COLLECT_MODES

List of valid collect modes.
Type:
list
Value:
['daily', 'weekly', 'incr']                                            

VALID_ARCHIVE_MODES

List of valid archive modes.
Type:
list
Value:
['tar', 'targz', 'tarbz2']                                             

VALID_ORDER_MODES

List of valid extension order modes.
Type:
list
Value:
['index', 'dependency']                                                

ACTION_NAME_REGEX

Type:
str
Value:
'^[a-z0-9]*$'                                                          

logger

Type:
Logger
Value:
<logging.Logger instance at 0x4030ee0c>                                

REWRITABLE_MEDIA_TYPES

Type:
list
Value:
['cdrw-74', 'cdrw-80', 'dvd+rw']                                       

VALID_BLANK_MODES

Type:
list
Value:
['daily', 'weekly']                                                    

VALID_CD_MEDIA_TYPES

Type:
list
Value:
['cdr-74', 'cdrw-74', 'cdr-80', 'cdrw-80']                             

VALID_COMPRESS_MODES

List of valid compress modes.
Type:
list
Value:
['none', 'gzip', 'bzip2']                                              

VALID_DVD_MEDIA_TYPES

Type:
list
Value:
['dvd+r', 'dvd+rw']                                                    

Generated by Epydoc 2.1 on Thu Mar 29 20:58:27 2007 http://epydoc.sf.net