Home | Trees | Indices | Help |
|
---|
|
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.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
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.
|
|||
peers Peers configuration in terms of a PeersConfig
object.
|
|||
Inherited from |
|
Initializes a configuration object. If you initialize the object without passing either
No reference to the original XML data or original path is saved off by this class. Once the data has been parsed (successfully or not) this original information is discarded. Unless thevalidate argument is False , the
Config.validate method will be called (with its default
arguments) against configuration after successfully parsing any passed-in
XML. Keep in mind that even if validate is
False , it might not be possible to parse the passed-in XML
document if lower-level validations fail.
Note:
It is strongly suggested that the |
|
|
|
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.
Note:
It is strongly suggested that the |
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).
|
None , the value must be a ReferenceConfig
object.
|
None , the value must be a ExtensionsConfig
object.
|
None , the value must be an OptionsConfig
object.
|
None , the value must be an PeersConfig
object.
|
None , the value must be a CollectConfig
object.
|
None , the value must be a StageConfig
object.
|
None , the value must be a StoreConfig
object.
|
None , the value must be a PurgeConfig
object.
|
Internal method to parse an XML string into the object. This method parses the XML document into a DOM tree
(
|
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
|
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.
|
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_command rshCommand //cb_config/options/rsh_command cbackCommand //cb_config/options/cback_command managedActions //cb_config/options/managed_actions The list of managed actions is a comma-separated list of action names. We also read groups of the following items, one list element per item:overrides //cb_config/options/override hooks //cb_config/options/hookThe overrides are parsed by _parseOverrides and the hooks are parsed by _parseHooks.
|
Parses a peers configuration section. We 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 _parsePeerList.
|
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}.
|
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 _parsePeerList.
|
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.
|
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.
|
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.
|
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
|
Reads a list of command command absolutePath abs_path
|
Reads a list of action action command command
|
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.
|
Reads a list of absolutePath abs_path collectMode mode I{or} collect_mode archiveMode archive_mode ignoreFile ignore_file linkDepth link_depth dereference dereference 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.
|
Reads a list of absolutePath <baseExpr>/abs_path retainDays <baseExpr>/retain_days
|
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 rshCommand rsh_command cbackCommand cback_command managed managed managedActions managed_actions Additionally, the value in the None will be returned for that item in the tuple.
|
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.
|
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.
|
Reads a single blankMode blank_behavior/mode blankFactor blank_behavior/factor
|
Internal method to extract configuration into an XML string. This method assumes that the internal validate method has been called prior to extracting the XML, if the caller cares. No validation will be done internally. As a general rule, fields that are set toNone 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.
|
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.
|
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 _addExtendedAction. IfextensionsConfig is None , then no
container will be added.
|
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_command rshCommand //cb_config/options/rsh_command cbackCommand //cb_config/options/cback_command managedActions //cb_config/options/managed_actionsWe 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 _addOverride. The individual hook items are added by _addHook. IfoptionsConfig is None , then no container
will be added.
|
Adds a <peers> configuration section as the next child of a parent. We add groups of the following items, one list element per item:localPeers //cb_config/peers/peer remotePeers //cb_config/peers/peer The individual local and remote peer entries are added by _addLocalPeer and _addRemotePeer, respectively. IfpeersConfig is None , then no container
will be added.
|
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 _addCollectFile and individual collect directories are added by _addCollectDir. IfcollectConfig is None , then no container
will be added.
|
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 _addLocalPeer and _addRemotePeer, respectively. IfstageConfig is None , then no container
will be added.
|
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 _addBlankBehavior method. IfstoreConfig is None , then no container
will be added.
|
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 _addPurgeDir. IfpurgeConfig is None , then no container
will be added.
|
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 _addDependencies method. 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.
|
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.
|
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.
|
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.
|
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 linkDepth dir/link_depth dereference dir/dereference 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.
|
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 ignoreFailureMode peer/ignore_failures 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.
|
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 rcpCommand peer/rcp_command rshCommand peer/rsh_command cbackCommand peer/cback_command ignoreFailureMode peer/ignore_failures managed peer/managed managedActions peer/managed_actions 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.
|
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.
|
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.
|
Creates a comma-separated string from a list of values. As a special case, ifvalueList is None ,
then None will be returned.
|
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.
|
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).
|
|
Validates extensions configuration. The list of actions may be either
|
Validates options configuration. All fields must be filled in except the rsh command. The rcp and rsh commands are used as default values for all remote peers. Remote peers can also rely on the backup user as the default remote user name if they choose.
|
|
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.
|
Validates stage configuration. The target directory must be filled in, and the peers are also validated. Peers are only required in this section if the peers configuration section is not filled in. However, if any peers are filled in here, they override the peers configuration and must meet the validation criteria in _validatePeerList.
|
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-
|
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.
|
Validates the set of local and remote peers. 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.
|
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.
|
|
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.
|
peersPeers configuration in terms of aPeersConfig object.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Sat Nov 15 12:16:57 2008 | http://epydoc.sourceforge.net |