freezer.utils.checksum.
CheckSum
(path, hasher_type='sha256', blocksize=1048576, exclude='', ignorelinks=False)¶Bases: object
Checksum a file or directory with sha256 or md5 algorithms.
This is used by backup and restore jobs to check for backup consistency.
the path to the file or directory to checksum
string
the hashing algorithm to use for checksum
string
hasher object for the specified hasher_type
hashlib object
the max. size of block to read when hashing a file
integer
pattern of files to exclude
string
final result for checksum computing
string
checksum without filename appended if unique file
string
number of files checksummed
int
compare
(checksum)¶Compute the checksum for the object path and compare with the given checksum. :return: boolean
compute
()¶Compute the checksum for the given path. If a single file is provided, the result is its checksum concatenated with its name. If a directory is provided, the result is the checksum of the checksum concatenation for each file. :return: string
get_files_hashes_in_path
()¶Walk the files in path computing the checksum for each one and updates the concatenation checksum for the final result
get_hash
(filepath)¶Open filename and calculate its hash. Append the hash to the previous result and stores the checksum for this concatenation :param filepath: path to file :type filepath: string :return: string containing the hash of the given file
hashes
= []¶hashfile
(afile)¶Checksum a single file with the chosen algorithm. The file is read in chunks of self.blocksize. :return: string
hashstring
(string)¶the hash for a given string
set_hasher
(hasher_type)¶Sets the hasher from hashlib according to the chosen hasher_type. Also sets the size of the expected output
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.