Package ganeti :: Package tools :: Module ensure_dirs
[hide private]
[frames] | no frames]

Module ensure_dirs

source code

Script to ensure permissions on files/dirs are accurate.

Classes [hide private]
  EnsureError
Top-level error class related to this script.
Functions [hide private]
 
EnsurePermission(path, mode, uid=-1, gid=-1, must_exist=True, _chmod_fn=os.chmod, _chown_fn=os.chown, _stat_fn=os.stat)
Ensures that given path has given mode.
source code
 
EnsureDir(path, mode, uid, gid, _lstat_fn=os.lstat, _mkdir_fn=os.mkdir, _ensure_fn=EnsurePermission)
Ensures that given path is a dir and has given mode, uid and gid set.
source code
 
RecursiveEnsure(path, uid, gid, dir_perm, file_perm)
Ensures permissions recursively down a directory.
source code
 
EnsureQueueDir(path, mode, uid, gid)
Sets the correct permissions on all job files in the queue.
source code
 
ProcessPath(path)
Processes a path component.
source code
 
GetPaths()
Returns a tuple of path objects to process.
source code
 
SetupLogging(opts)
Configures the logging module.
source code
 
ParseOptions()
Parses the options passed to the program.
source code
 
Main()
Main routine.
source code
Variables [hide private]
  ALL_TYPES = frozenset([DIR, FILE, QUEUE_DIR,])

Imports: errno, os, optparse, sys, stat, logging, constants, errors, runtime, ssconf, utils, cli


Function Details [hide private]

EnsurePermission(path, mode, uid=-1, gid=-1, must_exist=True, _chmod_fn=os.chmod, _chown_fn=os.chown, _stat_fn=os.stat)

source code 

Ensures that given path has given mode.

Parameters:
  • path - The path to the file
  • mode - The mode of the file
  • uid - The uid of the owner of this file
  • gid - The gid of the owner of this file
  • must_exist - Specifies if non-existance of path will be an error
  • _chmod_fn - chmod function to use (unittest only)
  • _chown_fn - chown function to use (unittest only)

EnsureDir(path, mode, uid, gid, _lstat_fn=os.lstat, _mkdir_fn=os.mkdir, _ensure_fn=EnsurePermission)

source code 

Ensures that given path is a dir and has given mode, uid and gid set.

Parameters:
  • path - The path to the file
  • mode - The mode of the file
  • uid - The uid of the owner of this file
  • gid - The gid of the owner of this file
  • _lstat_fn - Stat function to use (unittest only)
  • _mkdir_fn - mkdir function to use (unittest only)
  • _ensure_fn - ensure function to use (unittest only)

RecursiveEnsure(path, uid, gid, dir_perm, file_perm)

source code 

Ensures permissions recursively down a directory.

This functions walks the path and sets permissions accordingly.

Parameters:
  • path - The absolute path to walk
  • uid - The uid used as owner
  • gid - The gid used as group
  • dir_perm - The permission bits set for directories
  • file_perm - The permission bits set for files

EnsureQueueDir(path, mode, uid, gid)

source code 

Sets the correct permissions on all job files in the queue.

Parameters:
  • path - Directory path
  • mode - Wanted file mode
  • uid - Wanted user ID
  • gid - Wanted group ID

ProcessPath(path)

source code 

Processes a path component.

Parameters:
  • path - A tuple of the path component to process

ParseOptions()

source code 

Parses the options passed to the program.

Returns:
Options and arguments