def create_checksum(self):
"""
Creating a checksums of checksums to detect a change
even if there are multiple files used to configure a service.
Cleanup old checksumfiles if the config was removed.
"""
checksums = ''
for _file in self.service_conf_files:
if os.path.exists(_file):
log.debug("Generating checksum for {}".format(_file))
md5 = hashlib.md5(open(_file, 'rb').read()).hexdigest()
log.debug("Checksum: {}".format(md5))
checksums += md5
if checksums:
return hashlib.md5(checksums).hexdigest()
log.debug(("No file found to generate a checksum from. Looked for "
"{}".format(self.service_conf_files)))
if os.path.exists(self.checksum_file):
os.remove(self.checksum_file)
return None
评论列表
文章目录