diff --git a/diskutil.py b/diskutil.py index 68f49fbc..885c62f2 100644 --- a/diskutil.py +++ b/diskutil.py @@ -298,6 +298,9 @@ def getDiskDeviceSize(dev): return int(__readOneLineFile__("/sys/block/%s/device/block/size" % dev)) elif os.path.exists("/sys/block/%s/size" % dev): return int(__readOneLineFile__("/sys/block/%s/size" % dev)) + else: + raise Exception("%s not found as %s or %s" % (dev, "/sys/block/%s/device/block/size", + "/sys/block/%s/size")) def getDiskSerialNumber(dev): # For Multipath nodes return info about 1st slave diff --git a/product.py b/product.py index c07e12ee..72dbe766 100644 --- a/product.py +++ b/product.py @@ -559,13 +559,31 @@ def findXenSourceBackups(): b = None try: b = util.TempMount(p, 'backup-', ['ro'], 'ext3') - if os.path.exists(os.path.join(b.mount_point, '.xen-backup-partition')): - backup = XenServerBackup(p, b.mount_point) - logger.log("Found a backup: %s" % (repr(backup),)) - if backup.version >= XENSERVER_MIN_VERSION and \ - backup.version <= THIS_PLATFORM_VERSION: - backups.append(backup) - except: + if not os.path.exists(os.path.join(b.mount_point, '.xen-backup-partition')): + raise StopIteration() + + backup = XenServerBackup(p, b.mount_point) + logger.log("Found a backup: %s" % (repr(backup),)) + + if backup.version < XENSERVER_MIN_VERSION: + logger.log("findXenSourceBackups: ignoring, platform too old: %s < %s" % + (backup.version, XENSERVER_MIN_VERSION)) + raise StopIteration() + if backup.version > THIS_PLATFORM_VERSION: + logger.log("findXenSourceBackups: ignoring later platform: %s > %s" % + (backup.version, THIS_PLATFORM_VERSION)) + raise StopIteration() + if not os.path.exists(backup.root_disk): + logger.error("findXenSourceBackups: PRIMARY_DISK=%r does not exist" % + (backup.root_disk,)) + raise StopIteration() + + backups.append(backup) + + except StopIteration: + pass + except Exception as ex: + logger.log("findXenSourceBackups caught exception for partition %s: %s" % (p, ex)) pass if b: b.unmount()