def get_image_service(image_href, client=None, version=1, context=None):
    """Get image service instance to download the image.

    :param image_href: String containing href to get image service for.
    :param client: Glance client to be used for download, used only if
        image_href is Glance href.
    :param version: Version of Glance API to use, used only if image_href is
        Glance href.
    :param context: request context, used only if image_href is Glance href.
    :raises: exception.ImageRefValidationFailed if no image service can
        handle specified href.
    :returns: Instance of an image service class that is able to download
        specified image.
    """
    scheme = urlparse.urlparse(image_href).scheme.lower()
    try:
        cls = protocol_mapping[scheme or 'glance']
    except __HOLE__:
        raise exception.ImageRefValidationFailed(
            image_href=image_href,
            reason=_('Image download protocol '
                     '%s is not supported.') % scheme
        )

    if cls == GlanceImageService:
        return cls(client, version, context)
    return cls()
dataset/ETHPy150Open openstack/ironic/ironic/common/image_service.py/get_image_service