diff options
author | Rick Harris <rconradharris@gmail.com> | 2012-07-19 21:32:36 +0000 |
---|---|---|
committer | Rick Harris <rconradharris@gmail.com> | 2012-07-19 22:52:30 +0000 |
commit | 4881ccf017a217214ae30c74c2f7effbee71c044 (patch) | |
tree | 743d764a4d8892c61b73a045af70613720d53809 /plugins/xenserver | |
parent | b244f6fde2e4b85a01a8e0a340d12a1fa9073236 (diff) | |
download | nova-4881ccf017a217214ae30c74c2f7effbee71c044.tar.gz nova-4881ccf017a217214ae30c74c2f7effbee71c044.tar.xz nova-4881ccf017a217214ae30c74c2f7effbee71c044.zip |
Ensure VHDs in staging area are sequenced properly.
This adds a check to raise a sensible error if the VHDs in the staging
area are not sequence numbered properly, meaning 0 to n-1 with no gaps.
The previous error was an UnboundLookupError which made it difficult to
pinpoint the root cause.
Change-Id: I6b9e4f854c271bf73711480568be384ba883775d
Diffstat (limited to 'plugins/xenserver')
-rw-r--r-- | plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py index 20401b968..92ea80536 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py @@ -175,6 +175,24 @@ def _validate_vdi_chain(vdi_path): cur_path = get_parent_path(cur_path) +def _validate_sequenced_vhds(staging_path): + """This check ensures that the VHDs in the staging area are sequenced + properly from 0 to n-1 with no gaps. + """ + seq_num = 0 + filenames = os.listdir(staging_path) + for filename in filenames: + if not filename.endswith('.vhd'): + continue + + vhd_path = os.path.join(staging_path, "%d.vhd" % seq_num) + if not os.path.exists(vhd_path): + raise Exception("Corrupt image. Expected seq number: %d. Files: %s" + % (seq_num, filenames)) + + seq_num += 1 + + def import_vhds(sr_path, staging_path, uuid_stack): """Move VHDs from staging area into the SR. @@ -189,6 +207,7 @@ def import_vhds(sr_path, staging_path, uuid_stack): 'swap': {'uuid': 'ffff-bbbb'}} """ _handle_old_style_images(staging_path) + _validate_sequenced_vhds(staging_path) imported_vhds = {} files_to_move = [] |