diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-20 19:46:50 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-20 19:46:50 +0000 |
| commit | 4a9d44d4088bcd14479aafd6404ca93c6399e38c (patch) | |
| tree | 0a55188ea1188245b26374b58f768d754443ff19 /plugins | |
| parent | 1948137c9708608d9c39a643923c42b3419a7592 (diff) | |
| parent | 4881ccf017a217214ae30c74c2f7effbee71c044 (diff) | |
| download | nova-4a9d44d4088bcd14479aafd6404ca93c6399e38c.tar.gz nova-4a9d44d4088bcd14479aafd6404ca93c6399e38c.tar.xz nova-4a9d44d4088bcd14479aafd6404ca93c6399e38c.zip | |
Merge "Ensure VHDs in staging area are sequenced properly."
Diffstat (limited to 'plugins')
| -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 = [] |
