Esempio n. 1
0
File: api.py Progetto: tpot/dwarf
def _route_images_id(image_id):
    """
    Route:  /v1/images/<image_id>
    Method: GET, HEAD, DELETE, PUT
    """
    utils.show_request(bottle.request)

    # glance image-list
    if image_id == 'detail' and bottle.request.method == 'GET':
        return {'images': IMAGES.list()}

    # glance image-show <image_id>
    if image_id != 'detail' and bottle.request.method == 'HEAD':
        image = IMAGES.show(image_id)
        _add_header(image)
        return

    # glance image-delete <image_id>
    if image_id != 'detail' and bottle.request.method == 'DELETE':
        IMAGES.delete(image_id)
        return

    # glance image-update <image_id>
    if image_id != 'detail' and bottle.request.method == 'PUT':
        image_md = _from_headers(bottle.request.headers)
        return {'image': IMAGES.update(image_id, image_md)}

    bottle.abort(400, 'Unable to handle request')
Esempio n. 2
0
def _route_images_id(image_id):
    """
    Route:  /v1/images/<image_id>
    Method: GET, HEAD, DELETE, PUT
    """
    utils.show_request(bottle.request)

    # glance image-list
    if image_id == 'detail' and bottle.request.method == 'GET':
        return {'images': IMAGES.list()}

    # glance image-show <image_id>
    if image_id != 'detail' and bottle.request.method == 'HEAD':
        image = IMAGES.show(image_id)
        _add_header(image)
        return

    # glance image-delete <image_id>
    if image_id != 'detail' and bottle.request.method == 'DELETE':
        IMAGES.delete(image_id)
        return

    # glance image-update <image_id>
    if image_id != 'detail' and bottle.request.method == 'PUT':
        image_md = _from_headers(bottle.request.headers)
        return {'image': IMAGES.update(image_id, image_md)}

    bottle.abort(400, 'Unable to handle request')
Esempio n. 3
0
File: api.py Progetto: tpot/dwarf
def _route_images():
    """
    Route:  /v1/images
    Method: GET
    """
    utils.show_request(bottle.request)

    # Parse the HTTP header
    image_md = _from_headers(bottle.request.headers)

    # glance image-create
    image_fh = _request_body(bottle.request)
    return {'image': IMAGES.create(image_fh, image_md)}
Esempio n. 4
0
def _route_images():
    """
    Route:  /v1/images
    Method: GET
    """
    utils.show_request(bottle.request)

    # Parse the HTTP header
    image_md = _from_headers(bottle.request.headers)

    # glance image-create
    image_fh = _request_body(bottle.request)
    return {'image': IMAGES.create(image_fh, image_md)}