Package CedarBackup2 :: Module peer :: Class LocalPeer
[show private | hide private]
[frames | no frames]

Type LocalPeer

object --+
         |
        LocalPeer


Backup peer representing a local peer in a backup pool.

This is a class representing a local (non-network) peer in a backup pool. Local peers are backed up by simple filesystem copy operations. A local peer has associated with it a name (typically, but not necessarily, a hostname) and a collect directory.

The public methods other than the constructor are part of a "backup peer" interface shared with the RemotePeer class.
Method Summary
  __init__(self, name, collectDir)
Initializes a local backup peer.
  stagePeer(self, targetDir, ownership, permissions)
Stages data from the peer into the indicated local target directory.
  checkCollectIndicator(self, collectIndicator)
Checks the collect indicator in the peer's staging directory.
  writeStageIndicator(self, stageIndicator, ownership, permissions)
Writes the stage indicator in the peer's staging directory.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  name: Name of the peer.
  collectDir: Path to the peer's collect directory (an absolute local path).

Instance Method Details

__init__(self, name, collectDir)
(Constructor)

Initializes a local backup peer.

Note that the collect directory must be an absolute path, but does not have to exist when the object is instantiated. We do a lazy validation on this value since we could (potentially) be creating peer objects before an ongoing backup completed.
Parameters:
name - Name of the backup peer
           (type=String, typically a hostname)
collectDir - Path to the peer's collect directory
           (type=String representing an absolute local path on disk)
Raises:
ValueError - If the name is empty.
ValueError - If collect directory is not an absolute path.
Overrides:
__builtin__.object.__init__

stagePeer(self, targetDir, ownership=None, permissions=None)

Stages data from the peer into the indicated local target directory.

The collect and target directories must both already exist before this method is called. If passed in, ownership and permissions will be applied to the files that are copied.
Parameters:
targetDir - Target directory to write data into
           (type=String representing a directory on disk)
ownership - Owner and group that the staged files should have
           (type=Tuple of numeric ids (uid, gid))
permissions - Permissions that the staged files should have
           (type=UNIX permissions mode, specified in octal (i.e. 0640).)
Returns:
Number of files copied from the source directory to the target directory.
Raises:
ValueError - If collect directory is not a directory or does not exist
ValueError - If target directory is not a directory, does not exist or is not absolute.
ValueError - If a path cannot be encoded properly.
IOError - If there were no files to stage (i.e. the directory was empty)
IOError - If there is an IO error copying a file.
OSError - If there is an OS error copying or changing permissions on a file

Notes:

  • The caller is responsible for checking that the indicator exists, if they care. This function only stages the files within the directory.
  • If you have user/group as strings, call the util.getUidGid function to get the associated uid/gid as an ownership tuple.

checkCollectIndicator(self, collectIndicator=None)

Checks the collect indicator in the peer's staging directory.

When a peer has completed collecting its backup files, it will write an empty indicator file into its collect directory. This method checks to see whether that indicator has been written. We're "stupid" here - if the collect directory doesn't exist, you'll naturally get back False.

If you need to, you can override the name of the collect indicator file by passing in a different name.
Parameters:
collectIndicator - Name of the collect indicator file to check
           (type=String representing name of a file in the collect directory)
Returns:
Boolean true/false depending on whether the indicator exists.
Raises:
ValueError - If a path cannot be encoded properly.

writeStageIndicator(self, stageIndicator=None, ownership=None, permissions=None)

Writes the stage indicator in the peer's staging directory.

When the master has completed collecting its backup files, it will write an empty indicator file into the peer's collect directory. The presence of this file implies that the staging process is complete.

If you need to, you can override the name of the stage indicator file by passing in a different name.
Parameters:
stageIndicator - Name of the indicator file to write
           (type=String representing name of a file in the collect directory)
ownership - Owner and group that the indicator file should have
           (type=Tuple of numeric ids (uid, gid))
permissions - Permissions that the indicator file should have
           (type=UNIX permissions mode, specified in octal (i.e. 0640).)
Raises:
ValueError - If collect directory is not a directory or does not exist
ValueError - If a path cannot be encoded properly.
IOError - If there is an IO error creating the file.
OSError - If there is an OS error creating or changing permissions on the file

Note: If you have user/group as strings, call the util.getUidGid function to get the associated uid/gid as an ownership tuple.


Property Details

name

Name of the peer.

collectDir

Path to the peer's collect directory (an absolute local path).

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