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

[Xen-changelog] [xen-unstable] Cope with corrupt or empty VDI config files. Have to_record return strings



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1167063855 0
# Node ID eec06ba7afaa37208d79ef5763e0dd4a114518ec
# Parent  bd10d08598b07192e642e8ef8fe9fa76c5117689
Cope with corrupt or empty VDI config files.  Have to_record return strings
rather than integers, as required by the Xen-API spec.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendStorageRepository.py |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff -r bd10d08598b0 -r eec06ba7afaa 
tools/python/xen/xend/XendStorageRepository.py
--- a/tools/python/xen/xend/XendStorageRepository.py    Mon Dec 25 16:20:23 
2006 +0000
+++ b/tools/python/xen/xend/XendStorageRepository.py    Mon Dec 25 16:24:15 
2006 +0000
@@ -103,16 +103,16 @@ class XendStorageRepository:
         retval = {'uuid': self.uuid,
                   'name_label': self.name_label,
                   'name_description': self.name_description,
-                  'virtual_allocation': self.storage_alloc,
-                  'physical_utilisation': self.storage_used,
-                  'physical_size': self.storage_max,
+                  'virtual_allocation': str(self.storage_alloc),
+                  'physical_utilisation': str(self.storage_used),
+                  'physical_size': str(self.storage_max),
                   'type': self.type,
                   'location': self.location,
                   'VDIs': self.images.keys()}
         
         if self.storage_max == XEND_STORAGE_NO_MAXIMUM:
             stfs = os.statvfs(self.location)
-            retval['physical_size'] = stfs.f_blocks * stfs.f_frsize
+            retval['physical_size'] = str(stfs.f_blocks * stfs.f_frsize)
 
         return retval
         
@@ -148,7 +148,11 @@ class XendStorageRepository:
                                           virt_size, phys_size)
                         
                         if cfg_path and os.path.exists(cfg_path):
-                            vdi.load_config(cfg_path)
+                            try:
+                                vdi.load_config(cfg_path)
+                            except:
+                                log.error('Corrupt VDI configuration file %s' %
+                                          cfg_path)
                         
                         self.images[image_uuid] = vdi
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.