module documentation

Filesystem-based access functions and disk templates.

Class FileDeviceHelper No class docstring; 0/2 instance variable, 6/6 methods, 1/1 class method documented
Class FileStorage File device.
Function CheckFileStoragePath Checks whether the path exists and is acceptable to use.
Function CheckFileStoragePathAcceptance Checks if a path is allowed for file storage.
Function ComputeWrongFileStoragePaths Returns a list of file storage paths whose prefix is considered bad.
Function GetFileStorageSpaceInfo Retrieves the free and total space of the device where the file is located.
Function _CheckFileStoragePath Checks if a path is in a list of allowed paths for file storage.
Function _CheckFileStoragePathExistance Checks whether the given path is usable on the file system.
Function _ComputeWrongFileStoragePaths Cross-checks a list of paths for prefixes considered bad.
Function _GetForbiddenFileStoragePaths Builds a list of path prefixes which shouldn't be used for file storage.
Function _LoadAllowedFileStoragePaths Loads file containing allowed file storage paths.
def CheckFileStoragePath(path, _allowed_paths_file=pathutils.FILE_STORAGE_PATHS_FILE):

Checks whether the path exists and is acceptable to use.

Can be used for any file-based storage, for example shared-file storage.

Parameters
path:stringpath to check
_allowed_paths_fileUndocumented
Returns
stringerror message if the path is not ready to use
def CheckFileStoragePathAcceptance(path, _filename=pathutils.FILE_STORAGE_PATHS_FILE, exact_match_ok=False):

Checks if a path is allowed for file storage.

Parameters
path:stringPath to check
_filenameUndocumented
exact_match_okUndocumented
Raises
errors.FileStoragePathErrorIf the path is not allowed
def ComputeWrongFileStoragePaths(_filename=pathutils.FILE_STORAGE_PATHS_FILE):

Returns a list of file storage paths whose prefix is considered bad.

See _ComputeWrongFileStoragePaths.

def GetFileStorageSpaceInfo(path):

Retrieves the free and total space of the device where the file is located.

Parameters
path:stringPath of the file whose embracing device's capacity is reported.
Returns
a dictionary containing 'vg_size' and 'vg_free' given in MebiBytes
def _CheckFileStoragePath(path, allowed, exact_match_ok=False):

Checks if a path is in a list of allowed paths for file storage.

Parameters
path:stringPath to check
allowed:listList of allowed paths
exact_match_ok:boolwhether or not it is okay when the path is exactly equal to an allowed path and not a subdir of it
Raises
errors.FileStoragePathErrorIf the path is not allowed
def _CheckFileStoragePathExistance(path):

Checks whether the given path is usable on the file system.

This checks wether the path is existing, a directory and writable.

Parameters
path:stringpath to check
def _ComputeWrongFileStoragePaths(paths, _forbidden=_GetForbiddenFileStoragePaths()):

Cross-checks a list of paths for prefixes considered bad.

Some paths, e.g. "/bin", should not be used for file storage.

Parameters
paths:listList of paths to be checked
_forbiddenUndocumented
Returns
listSorted list of paths for which the user should be warned
def _GetForbiddenFileStoragePaths():

Builds a list of path prefixes which shouldn't be used for file storage.

Returns
frozensetUndocumented
def _LoadAllowedFileStoragePaths(filename):

Loads file containing allowed file storage paths.

Returns
listList of allowed paths (can be an empty list)