[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[et-mgmt-tools] [patch] virt-convert add disk signature into virt-image format export



Adds disk signatures into virt-convert for virt-image format virtual machines
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	Fri Sep 26 15:58:29 2008 -0400
@@ -22,7 +22,7 @@
 import virtconv.vmcfg as vmcfg
 import virtconv.diskcfg as diskcfg
 import virtinst.FullVirtGuest as fv
-
+import sha
 from xml.sax.saxutils import escape
 from string import ascii_letters
 import re
@@ -171,9 +171,11 @@
         type = "raw"
         if disk.type == diskcfg.DISK_TYPE_ISO:
             type = "iso"
+        diskfile=open(path,'r').read()
+        checksum=sha.new(diskfile).hexdigest()
         storage.append(
-            """<disk file="%s" use="system" format="%s"/>\n""" %
-                (path, type))
+            """<disk file="%s" use="system" format="%s">\n"""
+            """   <checksum type="sha1">%s</checksum>\n  </disk>\n""" % (path, type,checksum))
 
     return storage, diskout
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]