I'm done creating a sha256 hash setup should I offer more than just
sha256for now? and checksum generation is off by default
Here's a preview. Not sure how to catch the module import failure for
hashlib though
Cole Robinson wrote:
Daniel P. Berrange wrote:
On Tue, Sep 30, 2008 at 05:39:13PM -0400, Joey Boggs wrote:
Here's a sample that works, just want to verify it's alright. Is 64MB
too much/too little to read at one time?
f = open("test.raw","r")
m = sha.new()
while 1:
chunk = f.read(65536)
if not chunk:
break
m.update(chunk)
print m.hexdigest()
Both md5 and sha1 are becoming obsolete, and indeed forbidden by some
of the more paranoid organizations. I'd recommend we go straight
to using at least sha256. Also the docs recommend using hashlib module
directly, eg
import hashlib
m = hashlib.sha256()
while 1:
chunk = f.read(65536)
if not chunk:
break
m.update(chunk)
print m.hexdigest()
Daniel
Yeah, the only problem with hashlib is that it's python2.5
only. But we could just catch the import error and disable
the functionality if need be.
As far as md5 or sha1, no comment, though we probably want
to support whatever other config formats use (if any do
indeed offer hash support).
- Cole
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
diff -r 58a909b4f71c virt-convert
--- a/virt-convert Mon Sep 22 11:32:11 2008 -0400
+++ b/virt-convert Wed Oct 01 10:35:34 2008 -0400
@@ -64,6 +64,8 @@
opts.add_option("", "--os-variant", type="string", dest="os_variant",
action="callback", callback=cli.check_before_store,
help=("The OS variant for fully virtualized guests, e.g. 'fedora6', 'rhel5', 'solaris10', 'win2k', 'vista'"))
+ opts.add_option("", "--checksum", action="store_true", dest="checksum",
+ help=("Generate a checksum for a virt-image guest"))
opts.add_option("", "--noapic", action="store_true", dest="noapic",
help=("Disables APIC for fully virtualized guest (overrides value in os-type/os-variant db)"), default=False)
opts.add_option("", "--noacpi", action="store_true", dest="noacpi",
@@ -184,6 +186,9 @@
unixname = vmdef.name.replace(" ", "-")
+ if options.checksum:
+ vmdef.checksum = "yes"
+
if not options.output_dir:
options.output_dir = unixname
try:
diff -r 58a909b4f71c virtconv/parsers/virtimage.py
--- a/virtconv/parsers/virtimage.py Mon Sep 22 11:32:11 2008 -0400
+++ b/virtconv/parsers/virtimage.py Wed Oct 01 10:35:34 2008 -0400
@@ -26,6 +26,7 @@
from xml.sax.saxutils import escape
from string import ascii_letters
import re
+import hashlib
pv_boot_template = """
<boot type="xen">
@@ -167,14 +168,25 @@
# implement capabilities checking for max disks etc.
diskout.append("""<drive disk="%s" target="%s%s" />\n""" %
(path, disk_prefix, drive_nr))
-
type = "raw"
if disk.type == diskcfg.DISK_TYPE_ISO:
type = "iso"
- storage.append(
- """<disk file="%s" use="system" format="%s"/>\n""" %
- (path, type))
+ if vm.checksum == "yes":
+ hash = hashlib.sha256(path)
+ f = open(path,"r")
+ while 1:
+ chunk = f.read(65536)
+ if not chunk:
+ break
+ hash.update(chunk)
+ checksum = hash.hexdigest()
+ storage.append(
+ """<disk file="%s" use="system" format="%s">\n"""
+ """ <checksum type="sha256">%s</checksum>\n </disk>\n""" % (path, type,checksum))
+ else:
+ storage.append(
+ """<disk file="%s" use="system" format="%s">\n""" % (path, type))
return storage, diskout
class virtimage_parser(formats.parser):
diff -r 58a909b4f71c virtconv/vmcfg.py
--- a/virtconv/vmcfg.py Mon Sep 22 11:32:11 2008 -0400
+++ b/virtconv/vmcfg.py Wed Oct 01 10:35:34 2008 -0400
@@ -59,6 +59,7 @@
self.noapic = None
self.os_type = None
self.os_variant = None
+ self.checksum = None
def validate(self):
"""
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools