コード例 #1
0
def _image_info_v1(url, headers=None):
    """
    Return dict with image info. Only the "size" key is reported for v1 API.
    """
    resp = curlImgWrap.head(url, headers)

    try:
        return {"size": int(resp['X-Image-Meta-Size'])}
    except (KeyError, ValueError) as e:
        raise ImageSizeError(str(e), url, headers, resp)
コード例 #2
0
ファイル: imageSharing.py プロジェクト: rexhsu/vdsm
def httpGetSize(methodArgs):
    headers = curlImgWrap.head(methodArgs.get('url'),
                               methodArgs.get("headers", {}))

    size = None

    if 'Content-Length' in headers:
        size = int(headers['Content-Length'])

    # OpenStack Glance returns Content-Length = 0 so we need to
    # override the value with the content of the custom header
    # X-Image-Meta-Size.
    if 'X-Image-Meta-Size' in headers:
        size = max(size, int(headers['X-Image-Meta-Size']))

    if size is None:
        raise RuntimeError("Unable to determine image size")

    return size
コード例 #3
0
ファイル: imageSharing.py プロジェクト: EdDev/vdsm
def httpGetSize(methodArgs):
    headers = curlImgWrap.head(methodArgs.get('url'),
                               methodArgs.get("headers", {}))

    size = None

    if 'Content-Length' in headers:
        size = int(headers['Content-Length'])

    # OpenStack Glance returns Content-Length = 0 so we need to
    # override the value with the content of the custom header
    # X-Image-Meta-Size.
    if 'X-Image-Meta-Size' in headers:
        size = max(size, int(headers['X-Image-Meta-Size']))

    if size is None:
        raise RuntimeError("Unable to determine image size")

    return size