import textwrap


def image_upload_curl(auth, id, filepath):
    """Generates an cURL command to upload an image file at `filepath` to be
    associated with the Glance image. Includes authentication header, so
    is stateless and can be run most anywhere."""
    return textwrap.dedent('''\
    curl -i -X PUT -H "X-Auth-Token: {token}" \
        -H "Content-Type: application/octet-stream" \
        -H "Connection: keep-alive" \
        -T "{filepath}" \
        {url}'''.format(
        token=auth.token,
        filepath=filepath,
        url=auth.endpoint('image') + '/v2/images/{}/file'.format(id),
    ))