ia64/xen-unstable

changeset 13186:eec06ba7afaa

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@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Dec 25 16:24:15 2006 +0000 (2006-12-25)
parents bd10d08598b0
children 8036efeefbd1
files tools/python/xen/xend/XendStorageRepository.py
line diff
     1.1 --- a/tools/python/xen/xend/XendStorageRepository.py	Mon Dec 25 16:20:23 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendStorageRepository.py	Mon Dec 25 16:24:15 2006 +0000
     1.3 @@ -103,16 +103,16 @@ class XendStorageRepository:
     1.4          retval = {'uuid': self.uuid,
     1.5                    'name_label': self.name_label,
     1.6                    'name_description': self.name_description,
     1.7 -                  'virtual_allocation': self.storage_alloc,
     1.8 -                  'physical_utilisation': self.storage_used,
     1.9 -                  'physical_size': self.storage_max,
    1.10 +                  'virtual_allocation': str(self.storage_alloc),
    1.11 +                  'physical_utilisation': str(self.storage_used),
    1.12 +                  'physical_size': str(self.storage_max),
    1.13                    'type': self.type,
    1.14                    'location': self.location,
    1.15                    'VDIs': self.images.keys()}
    1.16          
    1.17          if self.storage_max == XEND_STORAGE_NO_MAXIMUM:
    1.18              stfs = os.statvfs(self.location)
    1.19 -            retval['physical_size'] = stfs.f_blocks * stfs.f_frsize
    1.20 +            retval['physical_size'] = str(stfs.f_blocks * stfs.f_frsize)
    1.21  
    1.22          return retval
    1.23          
    1.24 @@ -148,7 +148,11 @@ class XendStorageRepository:
    1.25                                            virt_size, phys_size)
    1.26                          
    1.27                          if cfg_path and os.path.exists(cfg_path):
    1.28 -                            vdi.load_config(cfg_path)
    1.29 +                            try:
    1.30 +                                vdi.load_config(cfg_path)
    1.31 +                            except:
    1.32 +                                log.error('Corrupt VDI configuration file %s' %
    1.33 +                                          cfg_path)
    1.34                          
    1.35                          self.images[image_uuid] = vdi
    1.36