def get_glance_client(context, image_href):
    """Get the correct glance client and id for the given image_href.

    The image_href param can be an href of the form
    http://myglanceserver:9292/images/42, or just an int such as 42. If the
    image_href is an int, then flags are used to create the default
    glance client.

    :param image_href: image ref/id for an image
    :returns: a tuple of the form (glance_client, image_id)

    """
    image_href = image_href or 0
    if str(image_href).isdigit():
        glance_host, glance_port = pick_glance_api_server()
        glance_client = _create_glance_client(context, glance_host,
                                              glance_port)
        return (glance_client, int(image_href))

    try:
        (image_id, host, port) = _parse_image_ref(image_href)
    except __HOLE__:
        raise exception.InvalidImageRef(image_href=image_href)
    glance_client = _create_glance_client(context, glance_host, glance_port)
    return (glance_client, image_id)
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/image/glance.py/get_glance_client