diff --git a/molecule/handlers.py b/molecule/handlers.py index a3b1b51..ec9e6c4 100644 --- a/molecule/handlers.py +++ b/molecule/handlers.py @@ -509,6 +509,17 @@ class IsoHandler(GenericHandlerInterface): _("built ISO image"),self.dest_iso, ) ) + if os.path.isfile(self.dest_iso) and os.access(self.dest_iso,os.R_OK): + self.Output.updateProgress("[%s|%s] %s: %s" % ( + blue("IsoHandler"),darkred(self.spec_name), + _("generating md5 for"),self.dest_iso, + ) + ) + digest = molecule.utils.md5sum(self.dest_iso) + md5file = self.dest_iso+".md5" + with open(md5file,"w") as f: + f.write("%s %s\n" % (os.path.basename(self.dest_iso),digest,)) + f.flush() return 0 diff --git a/molecule/utils.py b/molecule/utils.py index 728407a..4c4c380 100644 --- a/molecule/utils.py +++ b/molecule/utils.py @@ -85,3 +85,14 @@ def remove_path_sandbox(path, sandbox_env): def get_random_number(): return abs(hash(os.urandom(2)))%99999 + +def md5sum(filepath): + import hashlib + m = hashlib.md5() + readfile = open(filepath) + block = readfile.read(1024) + while block: + m.update(block) + block = readfile.read(1024) + readfile.close() + return m.hexdigest()