Package ganeti :: Package storage :: Module filestorage
[hide private]
[frames] | no frames]

Module filestorage

source code

File storage functions.

Functions [hide private]
 
GetFileStorageSpaceInfo(path)
Retrieves the free and total space of the device where the file is located.
source code
frozenset
_GetForbiddenFileStoragePaths()
Builds a list of path prefixes which shouldn't be used for file storage.
source code
list
_ComputeWrongFileStoragePaths(paths, _forbidden=_GetForbiddenFileStoragePaths())
Cross-checks a list of paths for prefixes considered bad.
source code
 
ComputeWrongFileStoragePaths(_filename=pathutils.FILE_STORAGE_PATHS_FILE)
Returns a list of file storage paths whose prefix is considered bad.
source code
 
_CheckFileStoragePath(path, allowed, exact_match_ok=False)
Checks if a path is in a list of allowed paths for file storage.
source code
list
_LoadAllowedFileStoragePaths(filename)
Loads file containing allowed file storage paths.
source code
 
CheckFileStoragePathAcceptance(path, _filename=pathutils.FILE_STORAGE_PATHS_FILE, exact_match_ok=False)
Checks if a path is allowed for file storage.
source code
 
_CheckFileStoragePathExistance(path)
Checks whether the given path is usable on the file system.
source code
string
CheckFileStoragePath(path, _allowed_paths_file=pathutils.FILE_STORAGE_PATHS_FILE)
Checks whether the path exists and is acceptable to use.
source code

Imports: logging, os, compat, constants, errors, pathutils, utils


Function Details [hide private]

GetFileStorageSpaceInfo(path)

source code 

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

Parameters:
  • path (string) - Path of the file whose embracing device's capacity is reported.
Returns:
a dictionary containing 'vg_size' and 'vg_free' given in MebiBytes

_ComputeWrongFileStoragePaths(paths, _forbidden=_GetForbiddenFileStoragePaths())

source code 

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

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

Parameters:
  • paths (list) - List of paths to be checked
Returns: list
Sorted list of paths for which the user should be warned

ComputeWrongFileStoragePaths(_filename=pathutils.FILE_STORAGE_PATHS_FILE)

source code 

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

See _ComputeWrongFileStoragePaths.

_CheckFileStoragePath(path, allowed, exact_match_ok=False)

source code 

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

Parameters:
  • path (string) - Path to check
  • allowed (list) - List of allowed paths
  • exact_match_ok (bool) - whether or not it is okay when the path is exactly equal to an allowed path and not a subdir of it
Raises:

_LoadAllowedFileStoragePaths(filename)

source code 

Loads file containing allowed file storage paths.

Returns: list
List of allowed paths (can be an empty list)

CheckFileStoragePathAcceptance(path, _filename=pathutils.FILE_STORAGE_PATHS_FILE, exact_match_ok=False)

source code 

Checks if a path is allowed for file storage.

Parameters:
  • path (string) - Path to check
Raises:

_CheckFileStoragePathExistance(path)

source code 

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

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

Parameters:
  • path (string) - path to check

CheckFileStoragePath(path, _allowed_paths_file=pathutils.FILE_STORAGE_PATHS_FILE)

source code 

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 (string) - path to check
Returns: string
error message if the path is not ready to use