diff options
| author | Rick Harris <rconradharris@gmail.com> | 2012-06-28 00:04:23 +0000 |
|---|---|---|
| committer | Rick Harris <rconradharris@gmail.com> | 2012-06-29 00:21:01 +0000 |
| commit | 27f23001d7023385367fb9022c200d4cdf6c022f (patch) | |
| tree | e6b56adbb8cf75422b4751882744f416a10d8c6b /plugins | |
| parent | 2c0083d84ab07be55e4cea49a3273e6890b22d3c (diff) | |
Dom0 plugin now returns data in proper format.
The virt-layer code was refactored so that a dict was used to pass
around which VDIs are present. This code makes the Dom0 plugin return
that same data structure so we don't have to perform an extra conversion
step.
Change-Id: Ib4f1b0082138d233eb0c3873bbc553395510bc8d
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 4 | ||||
| -rw-r--r-- | plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py | 22 |
2 files changed, 11 insertions, 15 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index b826a8711..58de40a01 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -263,13 +263,13 @@ def download_vhd(session, args): auth_token) # Move the VHDs from the staging area into the storage repository - vdi_list = utils.import_vhds(sr_path, staging_path, uuid_stack) + imported_vhds = utils.import_vhds(sr_path, staging_path, uuid_stack) finally: utils.cleanup_staging_area(staging_path) # Right now, it's easier to return a single string via XenAPI, # so we'll json encode the list of VHDs. - return json.dumps(vdi_list) + return json.dumps(imported_vhds) def upload_vhd(session, args): diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py index ff88501f3..77a0cf171 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py @@ -124,14 +124,10 @@ def import_vhds(sr_path, staging_path, uuid_stack): however, the chances of an SR.scan occuring between the rename()s invocations is so small that we can safely ignore it) - Returns: A list of VDIs. Each list element is a dictionary containing - information about the VHD. Dictionary keys are: - 1. "vdi_type" - The type of VDI. Currently they can be "root" or - "swap" - 2. "vdi_uuid" - The UUID of the VDI - - Example return: [{"vdi_type": "root","vdi_uuid": "ffff-aaa..vhd"}, - {"vdi_type": "swap","vdi_uuid": "ffff-bbb..vhd"}] + Returns: A dict of the VDIs imported. For example: + + {'root': {'uuid': 'ffff-aaaa'}, + 'swap': {'uuid': 'ffff-bbbb'}} """ def rename_with_uuid(orig_path): """Rename VHD using UUID so that it will be recognized by SR on a @@ -233,7 +229,7 @@ def import_vhds(sr_path, staging_path, uuid_stack): while cur_path: cur_path = get_parent_path(cur_path) - vdi_return_list = [] + imported_vhds = {} paths_to_move = [] image_parent = None @@ -258,23 +254,23 @@ def import_vhds(sr_path, staging_path, uuid_stack): # delete the base_copy since it is an unreferenced parent. paths_to_move.insert(0, snap_info[0]) # We return this snap as the VDI instead of image.vhd - vdi_return_list.append(dict(vdi_type="root", vdi_uuid=snap_info[1])) + imported_vhds['root'] = dict(uuid=snap_info[1]) else: validate_vdi_chain(image_info[0]) assert_vhd_not_hidden(image_info[0]) # If there's no snap, we return the image.vhd UUID - vdi_return_list.append(dict(vdi_type="root", vdi_uuid=image_info[1])) + imported_vhds['root'] = dict(uuid=image_info[1]) swap_info = prepare_if_exists(staging_path, 'swap.vhd') if swap_info: assert_vhd_not_hidden(swap_info[0]) paths_to_move.append(swap_info[0]) - vdi_return_list.append(dict(vdi_type="swap", vdi_uuid=swap_info[1])) + imported_vhds['swap'] = dict(uuid=swap_info[1]) for path in paths_to_move: move_into_sr(path) - return vdi_return_list + return imported_vhds def prepare_staging_area_for_upload(sr_path, staging_path, vdi_uuids): |
