Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail seeing a backup refering to non-existent disk #67

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions diskutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,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
Expand Down
32 changes: 25 additions & 7 deletions product.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,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()
Expand Down