human
Complete this python program:
def _fetch_vhd_image(context, session, instance, image_id):
assistant
#Here is the Python program you requested.

    """Tell glance to download an image and put the VHDs into the SR
    Returns: A list of dictionaries that describe VDIs
    """
    LOG.debug(_('Asking    xapi    to    fetch    vhd    image    %(image_id)s'), locals(), instance=instance)
    params = {'image_id': image_id, 'uuid_stack': _make_uuid_stack(), 'sr_path': get_sr_path(session)}
    if _image_uses_bittorrent(context, instance):
        plugin_name = 'bittorrent'
        callback = None
        params['torrent_base_url'] = CONF.xenapi_torrent_base_url
        params['torrent_seed_duration'] = CONF.xenapi_torrent_seed_duration
        params['torrent_seed_chance'] = CONF.xenapi_torrent_seed_chance
        params['torrent_max_last_accessed'] = CONF.xenapi_torrent_max_last_accessed
        params['torrent_listen_port_start'] = CONF.xenapi_torrent_listen_port_start
        params['torrent_listen_port_end'] = CONF.xenapi_torrent_listen_port_end
        params['torrent_download_stall_cutoff'] = CONF.xenapi_torrent_download_stall_cutoff
        params['torrent_max_seeder_processes_per_host'] = CONF.xenapi_torrent_max_seeder_processes_per_host
    else:
        plugin_name = 'glance'
        glance_api_servers = glance.get_api_servers()
        def pick_glance(params):
            (g_host, g_port, g_use_ssl) = glance_api_servers.next()
            params['glance_host'] = g_host
            params['glance_port'] = g_port
            params['glance_use_ssl'] = g_use_ssl
            params['auth_token'] = getattr(context, 'auth_token', None)
        callback = pick_glance
    vdis = _fetch_using_dom0_plugin_with_retry(context, session, image_id, plugin_name, params, callback=callback)
    sr_ref = safe_find_sr(session)
    _scan_sr(session, sr_ref)
    root_vdi_uuid = vdis['root']['uuid']
    set_vdi_name(session, root_vdi_uuid, instance['name'], 'root')
    _check_vdi_size(context, session, instance, root_vdi_uuid)
    return vdis