Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module config :: Class Config |
|
object
--+
|
Config
Class representing a Cedar Backup XML configuration document.
The Config
class is a Python object representation of a
Cedar Backup XML configuration file. It is intended to be the only
Python-language interface to Cedar Backup configuration on disk for both
Cedar Backup itself and for external applications.
The object 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.
This class and the classes it is composed from often use Python's
property
construct to validate input and limit access to
values. Some validations can only be done once a document is considered
"complete" (see module notes for more details).
Assignments to the various instance variables must match the expected
type, i.e. reference
must be a ReferenceConfig
.
The internal check uses the built-in isinstance
function, so
it should be OK to use subclasses if you want to.
None
. When an object is initialized without using an XML
document, all of the values will be None
. Even when an
object is initialized using XML, some of the values might be
None
because not every section is required.
Note: Lists within this class are "unordered" for equality comparisons.
Method Summary | |
---|---|
Initializes a configuration object. | |
Official string representation for class instance. | |
Informal string representation for class instance. | |
Definition of equals operator for this class. | |
Extracts configuration into an XML document. | |
Validates configuration represented by the object. | |
Property target used to get the reference configuration value. | |
Property target used to set the reference configuration value. | |
Property target used to get the extensions configuration value. | |
Property target used to set the extensions configuration value. | |
Property target used to get the options configuration value. | |
Property target used to set the options configuration value. | |
Property target used to get the collect configuration value. | |
Property target used to set the collect configuration value. | |
Property target used to get the stage configuration value. | |
Property target used to set the stage configuration value. | |
Property target used to get the store configuration value. | |
Property target used to set the store configuration value. | |
Property target used to get the purge configuration value. | |
Property target used to set the purge configuration value. | |
Adds a blanking behavior container as the next child of a parent. (Static method) | |
Adds a <collect> configuration section as the next child of a parent. (Static method) | |
Adds a collect directory container as the next child of a parent. (Static method) | |
Adds a collect file container as the next child of a parent. (Static method) | |
Adds a extended action dependencies to parent node. (Static method) | |
Adds an extended action container as the next child of a parent. (Static method) | |
Adds an <extensions> configuration section as the next child of a parent. (Static method) | |
Adds an action hook container as the next child of a parent. (Static method) | |
Adds a local peer container as the next child of a parent. (Static method) | |
Adds a <options> configuration section as the next child of a parent. (Static method) | |
Adds a command override container as the next child of a parent. (Static method) | |
Adds a <purge> configuration section as the next child of a parent. (Static method) | |
Adds a purge directory container as the next child of a parent. (Static method) | |
Adds a <reference> configuration section as the next child of a parent. (Static method) | |
Adds a remote peer container as the next child of a parent. (Static method) | |
Adds a <stage> configuration section as the next child of a parent. (Static method) | |
Adds a <store> configuration section as the next child of a parent. (Static method) | |
Creates a comma-separated string from a list of values. (Static method) | |
Checks that all values are unique. (Static method) | |
Internal method to extract configuration into an XML string. | |
Reads a single BlankBehavior object from immediately
beneath the parent. (Static method)
| |
Parses a collect configuration section. (Static method) | |
Reads a list of CollectDir objects from immediately
beneath the parent. (Static method)
| |
Reads a list of CollectFile objects from immediately
beneath the parent. (Static method)
| |
Parses a list of values out of a comma-separated string. (Static method) | |
Reads extended action dependency information from a parent node. (Static method) | |
Reads exclusions data from immediately beneath the parent. (Static method) | |
Reads extended actions data from immediately beneath the parent. (Static method) | |
Parses an extensions configuration section. (Static method) | |
Reads a list of ActionHook objects from immediately
beneath the parent. (Static method)
| |
Parses a options configuration section. (Static method) | |
Reads a list of CommandOverride objects from immediately
beneath the parent. (Static method)
| |
Reads remote and local peer data from immediately beneath the parent. (Static method) | |
Parses a purge configuration section. (Static method) | |
Reads a list of PurgeDir objects from immediately beneath
the parent. (Static method)
| |
Parses a reference configuration section. (Static method) | |
Parses a stage configuration section. (Static method) | |
Parses a store configuration section. (Static method) | |
Internal method to parse an XML string into the object. | |
Validates collect configuration. | |
Validates configuration contents per rules discussed in module documentation. | |
Validates extensions configuration. | |
Validates options configuration. | |
Validates purge configuration. | |
Validates reference configuration. | |
Validates stage configuration. | |
Validates store configuration. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value |
Property Summary | |
---|---|
reference : Reference configuration in terms of a ReferenceConfig
object. | |
extensions : Extensions configuration in terms of a ExtensionsConfig
object. | |
options : Options configuration in terms of a OptionsConfig
object. | |
collect : Collect configuration in terms of a CollectConfig
object. | |
stage : Stage configuration in terms of a StageConfig object. | |
store : Store configuration in terms of a StoreConfig object. | |
purge : Purge configuration in terms of a PurgeConfig object. |
Instance Method Details |
---|
__init__(self,
xmlData=None,
xmlPath=None,
validate=True)
|
__repr__(self)
Official string representation for class instance.
|
__str__(self)
Informal string representation for class instance.
|
__cmp__(self,
other)
Definition of equals operator for this class. Lists within this
class are "unordered" for equality comparisons.
|
extractXml(self, xmlPath=None, validate=True)Extracts configuration into an XML document. If validate parameter is False ,
the Config.validate method will be called
(with its default arguments) against the configuration before
extracting the XML. If configuration is not valid, then an XML document
will not be extracted.
|
validate(self, requireOneAction=True, requireReference=False, requireExtensions=False, requireOptions=True, requireCollect=False, requireStage=False, requireStore=False, requirePurge=False)Validates configuration represented by the object. This method encapsulates all of the validations that should apply to a fully "complete" document but are not already taken care of by earlier validations. It also provides some extra convenience functionality which might be useful to some people. The process of validation is laid out in the Validation section in the class notes (above).
|
_getReference(self)Property target used to get the reference configuration value. |
_setReference(self, value)Property target used to set the reference configuration value. If notNone , the value must be a ReferenceConfig
object.
|
_getExtensions(self)Property target used to get the extensions configuration value. |
_setExtensions(self, value)Property target used to set the extensions configuration value. If notNone , the value must be a
ExtensionsConfig object.
|
_getOptions(self)Property target used to get the options configuration value. |
_setOptions(self, value)Property target used to set the options configuration value. If notNone , the value must be an OptionsConfig
object.
|
_getCollect(self)Property target used to get the collect configuration value. |
_setCollect(self, value)Property target used to set the collect configuration value. If notNone , the value must be a CollectConfig
object.
|
_getStage(self)Property target used to get the stage configuration value. |
_setStage(self, value)Property target used to set the stage configuration value. If notNone , the value must be a StageConfig
object.
|
_getStore(self)Property target used to get the store configuration value. |
_setStore(self, value)Property target used to set the store configuration value. If notNone , the value must be a StoreConfig
object.
|
_getPurge(self)Property target used to get the purge configuration value. |
_setPurge(self, value)Property target used to set the purge configuration value. If notNone , the value must be a PurgeConfig
object.
|
_extractXml(self)Internal method to extract configuration into an XML string. This method assumes that the internal None will be
extracted into the document as empty tags. The same goes for container
tags that are filled based on lists - if the list is empty or
None , the container tag will be empty.
|
_parseXmlData(self, xmlData)Internal method to parse an XML string into the object. This method parses the XML document into a DOM tree
( validate method).
|
_validateCollect(self)Validates collect configuration. 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 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.
|
_validateContents(self)Validates configuration contents per rules discussed in module documentation. This is the second pass at validation. It ensures that any filled-in section contains valid data. Any sections which is not set toNone is validated per the rules for that section, laid out
in the module documentation (above).
|
_validateExtensions(self)Validates extensions configuration. The list of actions may be either
|
_validateOptions(self)Validates options configuration. 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.
|
_validatePurge(self)Validates purge configuration. The list of purge directories may be eitherNone or an
empty list [] if desired. All purge directories must
contain a path and a retain days value.
|
_validateReference(self)Validates reference configuration. There are currently no reference-related validations.
|
_validateStage(self)Validates stage configuration. 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
|
_validateStore(self)Validates store configuration. The device type, drive speed, and blanking behavior are optional. All other values are required. Missing booleans will be set to defaults. If blanking behavior is provided, then both a blanking mode and a blanking factor are required. The image writer functionality in the Any caller which needs a "real" (non-
|
Static Method Details |
---|
_addBlankBehavior(xmlDom, parentNode, blankBehavior)Adds a blanking behavior container as the next child of a parent. We add the following fields to the document:blankMode blank_behavior/mode blankFactor blank_behavior/factor The <blank_behavior> node itself is created as the next child of the parent node. IfblankBehavior is None , this method call
will be a no-op.
|
_addCollect(xmlDom, parentNode, collectConfig)Adds a <collect> configuration section as the next child of a parent. We add the following fields to the document:targetDir //cb_config/collect/collect_dir collectMode //cb_config/collect/collect_mode archiveMode //cb_config/collect/archive_mode ignoreFile //cb_config/collect/ignore_fileWe also add groups of the following items, one list element per item: absoluteExcludePaths //cb_config/collect/exclude/abs_path excludePatterns //cb_config/collect/exclude/pattern collectFiles //cb_config/collect/file collectDirs //cb_config/collect/dir The individual collect files are added by collectConfig is None , then no
container will be added.
|
_addCollectDir(xmlDom, parentNode, collectDir)Adds a collect directory container as the next child of a parent. We add the following fields to the document:absolutePath dir/abs_path collectMode dir/collect_mode archiveMode dir/archive_mode ignoreFile dir/ignore_file Note that an original XML document might have listed the collect
mode using the absoluteExcludePaths dir/exclude/abs_path relativeExcludePaths dir/exclude/rel_path excludePatterns dir/exclude/pattern The <dir> node itself is created as the next child of the
parent node. This method only adds one collect directory node. The
parent must loop for each collect directory in the
collectDir is None , this method call
will be a no-op.
|
_addCollectFile(xmlDom, parentNode, collectFile)Adds a collect file container as the next child of a parent. We add the following fields to the document:absolutePath dir/abs_path collectMode dir/collect_mode archiveMode dir/archive_mode Note that for consistency with collect directory handling we'll only
emit the preferred The <file> node itself is created as the next child of the
parent node. This method only adds one collect file node. The parent
must loop for each collect file in the collectFile is None , this method call
will be a no-op.
|
_addDependencies(xmlDom, parentNode, dependencies)Adds a extended action dependencies to parent node. We add the following fields to the document:runBefore depends/run_before runAfter depends/run_afterIf dependencies is None , this method call
will be a no-op.
|
_addExtendedAction(xmlDom, parentNode, action)Adds an extended action container as the next child of a parent. We add the following fields to the document:name action/name module action/module function action/function index action/index dependencies action/depends Dependencies are added by the The <action> node itself is created as the next child of the
parent node. This method only adds one action node. The parent must
loop for each action in the action is None , this method call will
be a no-op.
|
_addExtensions(xmlDom, parentNode, extensionsConfig)Adds an <extensions> configuration section as the next child of a parent. We add the following fields to the document:order_mode //cb_config/extensions/order_modeWe also add groups of the following items, one list element per item: actions //cb_config/extensions/action The extended action entries are added by extensionsConfig is None , then no
container will be added.
|
_addHook(xmlDom, parentNode, hook)Adds an action hook container as the next child of a parent. The behavior varies depending on the value of thebefore and after flags on the hook. If the
before flag is set, it's a pre-action hook, and we'll add
the following fields:
action pre_action_hook/action command pre_action_hook/commandIf the after flag is set, it's a post-action hook, and
we'll add the following fields:
action post_action_hook/action command post_action_hook/command The <pre_action_hook> or <post_action_hook> node itself
is created as the next child of the parent node. This method only adds
one hook node. The parent must loop for each hook in the
hook is None , this method call will be
a no-op.
|
_addLocalPeer(xmlDom, parentNode, localPeer)Adds a local peer container as the next child of a parent. We add the following fields to the document:name peer/name collectDir peer/collect_dir Additionally, The <peer> node itself is created as the next child of the
parent node. This method only adds one peer node. The parent must loop
for each peer in the localPeer is None , this method call
will be a no-op.
|
_addOptions(xmlDom, parentNode, optionsConfig)Adds a <options> configuration section as the next child of a parent. We add the following fields to the document:startingDay //cb_config/options/starting_day workingDir //cb_config/options/working_dir backupUser //cb_config/options/backup_user backupGroup //cb_config/options/backup_group rcpCommand //cb_config/options/rcp_commandWe also add groups of the following items, one list element per item: overrides //cb_config/options/override hooks //cb_config/options/pre_action_hook hooks //cb_config/options/post_action_hook The individual override items are added by optionsConfig is None , then no
container will be added.
|
_addOverride(xmlDom, parentNode, override)Adds a command override container as the next child of a parent. We add the following fields to the document:command override/command absolutePath override/abs_path The <override> node itself is created as the next child of the
parent node. This method only adds one override node. The parent must
loop for each override in the override is None , this method call will
be a no-op.
|
_addPurge(xmlDom, parentNode, purgeConfig)Adds a <purge> configuration section as the next child of a parent. We add the following fields to the document:purgeDirs //cb_config/purge/dir The individual directory entries are added by purgeConfig is None , then no container
will be added.
|
_addPurgeDir(xmlDom, parentNode, purgeDir)Adds a purge directory container as the next child of a parent. We add the following fields to the document:absolutePath dir/abs_path retainDays dir/retain_days The <dir> node itself is created as the next child of the
parent node. This method only adds one purge directory node. The parent
must loop for each purge directory in the purgeDir is None , this method call will
be a no-op.
|
_addReference(xmlDom, parentNode, referenceConfig)Adds a <reference> configuration section as the next child of a parent. We add the following fields to the document:author //cb_config/reference/author revision //cb_config/reference/revision description //cb_config/reference/description generator //cb_config/reference/generatorIf referenceConfig is None , then no
container will be added.
|
_addRemotePeer(xmlDom, parentNode, remotePeer)Adds a remote peer container as the next child of a parent. We add the following fields to the document:name peer/name collectDir peer/collect_dir remoteUser peer/backup_user rcpCommand peer/rcp_command Additionally, The <peer> node itself is created as the next child of the
parent node. This method only adds one peer node. The parent must loop
for each peer in the remotePeer is None , this method call
will be a no-op.
|
_addStage(xmlDom, parentNode, stageConfig)Adds a <stage> configuration section as the next child of a parent. We add the following fields to the document:targetDir //cb_config/stage/staging_dirWe also add groups of the following items, one list element per item: localPeers //cb_config/stage/peer remotePeers //cb_config/stage/peer The individual local and remote peer entries are added by stageConfig is None , then no container
will be added.
|
_addStore(xmlDom, parentNode, storeConfig)Adds a <store> configuration section as the next child of a parent. We add the following fields to the document:sourceDir //cb_config/store/source_dir mediaType //cb_config/store/media_type deviceType //cb_config/store/device_type devicePath //cb_config/store/target_device deviceScsiId //cb_config/store/target_scsi_id driveSpeed //cb_config/store/drive_speed checkData //cb_config/store/check_data checkMedia //cb_config/store/check_media warnMidnite //cb_config/store/warn_midnite noEject //cb_config/store/no_eject Blanking behavior configuration is added by the storeConfig is None , then no container
will be added.
|
_buildCommaSeparatedString(valueList)Creates a comma-separated string from a list of values. As a special case, ifvalueList is None ,
then None will be returned.
|
_checkUnique(prefix, values)Checks that all values are unique. The values list is checked for duplicate values. If there are duplicates, an exception is thrown. All duplicate values are listed in the exception.
|
_parseBlankBehavior(parentNode)Reads a single blankMode blank_behavior/mode blankFactor blank_behavior/factor
|
_parseCollect(parentNode)Parses a collect configuration section. We read the following individual fields:targetDir //cb_config/collect/collect_dir collectMode //cb_config/collect/collect_mode archiveMode //cb_config/collect/archive_mode ignoreFile //cb_config/collect/ignore_fileWe also read groups of the following items, one list element per item: absoluteExcludePaths //cb_config/collect/exclude/abs_path excludePatterns //cb_config/collect/exclude/pattern collectFiles //cb_config/collect/file collectDirs //cb_config/collect/dir The exclusions are parsed by L{_parseExclusions}, the collect files are parsed by L{_parseCollectFiles}, and the directories are parsed by L{_parseCollectDirs}.
|
_parseCollectDirs(parentNode)Reads a list of absolutePath abs_path collectMode mode I{or} collect_mode archiveMode archive_mode ignoreFile ignore_file The collect mode is a special case. Just a absoluteExcludePaths exclude/abs_path relativeExcludePaths exclude/rel_path excludePatterns exclude/patternThe exclusions are parsed by _parseExclusions .
|
_parseCollectFiles(parentNode)Reads a list of absolutePath abs_path collectMode mode I{or} collect_mode archiveMode archive_modeThe collect mode is a special case. Just a mode tag is
accepted, but we prefer collect_mode for consistency with
the rest of the config file and to avoid confusion with the archive
mode. If both are provided, only mode will be used.
|
_parseCommaSeparatedString(commaString)Parses a list of values out of a comma-separated string. The items in the list are split by comma, and then have whitespace stripped. As a special case, ifcommaString is
None , then None will be returned.
|
_parseDependencies(parentNode)Reads extended action dependency information from a parent node. We read the following individual fields:runBefore depends/run_before runAfter depends/run_after Each of these fields is a comma-separated list of action names. The result is placed into an None
will be returned. Otherwise, an ActionDependencies object
will always be created, even if it does not contain any actual
dependencies in it.
|
_parseExclusions(parentNode)Reads exclusions data from immediately beneath the parent. We read groups of the following items, one list element per item:absolute exclude/abs_path relative exclude/rel_path patterns exclude/pattern If there are none of some pattern (i.e. no relative path items) then
|
_parseExtendedActions(parentNode)Reads extended actions data from immediately beneath the parent. We read the following individual fields from each extended action:name name module module function function index index dependencies dependsDependency information is parsed by the _parseDependencies method.
|
_parseExtensions(parentNode)Parses an extensions configuration section. We read the following fields:orderMode //cb_config/extensions/order_modeWe also read groups of the following items, one list element per item: name //cb_config/extensions/action/name module //cb_config/extensions/action/module function //cb_config/extensions/action/function index //cb_config/extensions/action/index dependencies //cb_config/extensions/action/dependsThe extended actions are parsed by _parseExtendedActions .
|
_parseHooks(parentNode)Reads a list of action action command command
|
_parseOptions(parentNode)Parses a options configuration section. We read the following fields:startingDay //cb_config/options/starting_day workingDir //cb_config/options/working_dir backupUser //cb_config/options/backup_user backupGroup //cb_config/options/backup_group rcpCommand //cb_config/options/rcp_commandWe also read groups of the following items, one list element per item: overrides //cb_config/options/overrideThe overrides are parsed by _parseOverrides .
|
_parseOverrides(parentNode)Reads a list of command command absolutePath abs_path
|
_parsePeers(parentNode)Reads remote and local peer data from immediately beneath the parent. We read the following individual fields for both remote and local peers:name name collectDir collect_dirWe also read the following individual fields for remote peers only: remoteUser backup_user rcpCommand rcp_command Additionally, the value in the None will be returned for that item in the tuple.
|
_parsePurge(parentNode)Parses a purge configuration section. We read groups of the following items, one list element per item:purgeDirs //cb_config/purge/dirThe individual directory entries are parsed by _parsePurgeDirs .
|
_parsePurgeDirs(parentNode)Reads a list of absolutePath <baseExpr>/abs_path retainDays <baseExpr>/retain_days
|
_parseReference(parentNode)Parses a reference configuration section. We read the following fields:author //cb_config/reference/author revision //cb_config/reference/revision description //cb_config/reference/description generator //cb_config/reference/generator
|
_parseStage(parentNode)Parses a stage configuration section. We read the following individual fields:targetDir //cb_config/stage/staging_dirWe also read groups of the following items, one list element per item: localPeers //cb_config/stage/peer remotePeers //cb_config/stage/peerThe individual peer entries are parsed by _parsePeers .
|
_parseStore(parentNode)Parses a store configuration section. We read the following fields:sourceDir //cb_config/store/source_dir mediaType //cb_config/store/media_type deviceType //cb_config/store/device_type devicePath //cb_config/store/target_device deviceScsiId //cb_config/store/target_scsi_id driveSpeed //cb_config/store/drive_speed checkData //cb_config/store/check_data checkMedia //cb_config/store/check_media warnMidnite //cb_config/store/warn_midnite noEject //cb_config/store/no_ejectBlanking behavior configuration is parsed by the _parseBlankBehavior method.
|
Property Details |
---|
referenceReference configuration in terms of aReferenceConfig
object.
|
extensionsExtensions configuration in terms of aExtensionsConfig
object.
|
optionsOptions configuration in terms of aOptionsConfig
object.
|
collectCollect configuration in terms of aCollectConfig
object.
|
stageStage configuration in terms of aStageConfig object.
|
storeStore configuration in terms of aStoreConfig object.
|
purgePurge configuration in terms of aPurgeConfig object.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Mar 29 20:58:26 2007 | http://epydoc.sf.net |