Class: Visor::Image::Server
- Inherits:
-
Goliath::API
- Object
- Goliath::API
- Visor::Image::Server
- Defined in:
- lib/image/server.rb
Overview
The VISoR Image Server. This supports all image metadata manipulation operations, dispatched to the VISoR Meta Server and the image files storage operations.
*The Server API is a RESTful web service for image meta as follows:*
HEAD /images/<id> - Returns metadata about the image with the given id
GET /images - Returns a set of brief metadata about all public images
GET /images/detail - Returns a set of detailed metadata about all public images
GET /images/<id> - Returns image data and metadata for the image with the given id
POST /images - Stores a new image data and metadata and returns the registered metadata
PUT /images/<id> - Update image metadata and/or data for the image with the given id
DELETE /images/<id> - Delete the metadata and data of the image with the given id
The Image is multi-format, most properly it supports response encoding in JSON and XML formats. It will auto negotiate and encode the response metadata and error messages in the proper format, based on the request Accept header, being it ‘application/json’ or ‘application/xml’. If no Accept header is provided, Image will encode and render it as JSON by default.
This server routes all metadata operations to the Visor Meta Server.
The server will interact with the multiple supported backend store to manage the image files.
*Currently we support the following store backend and operations:*
Amazon Simple Storage (s3) - GET, POST, PUT, DELETE
Nimbus Cumulus (cumulus) - GET, POST, PUT, DELETE
Eucalyptus Walrus (walrus) - GET, POST, PUT, DELETE
Local Filesystem (file) - GET, POST, PUT, DELETE
Remote HTTP (http) - GET
Instance Method Summary collapse
-
#delete('/images/: id') ⇒ JSON, XML
Delete the metadata and data of the image with the given id, see DeleteImage.
-
#get('/images') ⇒ JSON, XML
Get brief information about all public images, see GetImages.
-
#get('/images/detail') ⇒ JSON, XML
Get detailed information about all public images, see GetImagesDetail.
-
#get('/images/: id') ⇒ HTTP Headers, HTTP Body
Get image data and detailed metadata for the given id, see GetImage.
-
#head('/image/: id') ⇒ HTTP Headers
Head metadata about the image with the given id, see HeadImage.
-
#post('/images') ⇒ JSON, XML
Post image data and metadata and returns the registered metadata, see PostImage.
-
#put('/images/: id') ⇒ JSON, XML
Put image metadata and/or data for the image with the given id, see PutImage.
Instance Method Details
#delete('/images/: id') ⇒ JSON, XML
Delete the metadata and data of the image with the given id, see DeleteImage.
296 |
# File 'lib/image/server.rb', line 296 delete '/images/:id', DeleteImage |
#get('/images') ⇒ JSON, XML
Get brief information about all public images, see GetImages.
{ "images":
[
{
"_id":<_id>,
"uri":<uri>,
"name":<name>,
"architecture":<architecture>,
"type":<type>,
"format":<format>,
"store":<type>,
"size":<size>,
"created_at":<timestamp>
},
...
]
}
The following options can be passed as query parameters, plus any other additional image attribute not defined in the schema.
127 |
# File 'lib/image/server.rb', line 127 get '/images', GetImages |
#get('/images/detail') ⇒ JSON, XML
Querying and ordering results are made as with #get_all_detail
Get detailed information about all public images, see GetImagesDetail.
{ "images":
[
{
"_id":<_id>,
"uri":<uri>,
"name":<name>,
"architecture":<architecture>,
"access":<access>,
"status":<status>,
"size":<size>,
"type":<type>,
"format":<format>,
"store":<store>,
"created_at":<timestamp>
"updated_at":<timestamp>,
"kernel":<associated kernel>,
"ramdisk":<associated ramdisk>,
},
...
]
}
The following options can be passed as query parameters, plus any other additional image attribute not defined in the schema.
174 |
# File 'lib/image/server.rb', line 174 get '/images/detail', GetImagesDetail |
#get('/images/: id') ⇒ HTTP Headers, HTTP Body
Undefined attributes are ignored and not included into response’s header.
Get image data and detailed metadata for the given id, see GetImage.
The image data file is streamed as response’s body. The server will return a 200 status code, with a special HTTP header, indicating that the response body will be streamed in chunks and connection shouldn’t be closed until the transfer is complete.
Also, the image metadata is promptly passed as a set of HTTP headers, as the following example:
x-image-meta-_id: <id>
x-image-meta-uri: <uri>
x-image-meta-name: <name>
x-image-meta-architecture: <architecture>
x-image-meta-access: <access>
x-image-meta-status: <status>
x-image-meta-created_at: <timestamp>
209 |
# File 'lib/image/server.rb', line 209 get '/images/:id', GetImage |
#head('/image/: id') ⇒ HTTP Headers
Undefined attributes are ignored and not included into response’s header. Also any raised error will be passed through HTTP headers as expected.
Head metadata about the image with the given id, see HeadImage.
The image metadata is promptly passed as a set of HTTP headers, as the following example:
x-image-meta-_id: <id>
x-image-meta-uri: <uri>
x-image-meta-name: <name>
x-image-meta-architecture: <architecture>
x-image-meta-access: <access>
x-image-meta-status: <status>
x-image-meta-created_at: <timestamp>
81 |
# File 'lib/image/server.rb', line 81 head '/images/:id', HeadImage |
#post('/images') ⇒ JSON, XML
Post image data and metadata and returns the registered metadata, see PostImage.
The image metadata should be encoded as HTTP headers and passed with the request, as the following example:
x-image-meta-name: Ubuntu 10.10 Desktop
x-image-meta-architecture: i386
x-image-meta-store: s3
If wanted, the image data file should be streamed through the request body. The server will receive that data in chunks, buffering them to a properly secured temporary file, avoiding buffering all the data into memory. Server will then handle the upload of that data to the definitive store location, cleaning then the generated temporary file.
Alternatively, a x-image-meta-location header can be passed, if the file is already stored in some provided location. If this header is present, no body content can be passed in the request.
241 |
# File 'lib/image/server.rb', line 241 post '/images', PostImage |
#put('/images/: id') ⇒ JSON, XML
Only images with status set to ‘locked’ or ‘error’ can be updated with an image data file.
Put image metadata and/or data for the image with the given id, see PutImage.
The image metadata should be encoded as HTTP headers and passed with the request, as the following example:
x-image-meta-name: Ubuntu 10.10 Server
x-image-meta-architecture: x86_64
x-image-meta-location: http://www.ubuntu.com/start-download?distro=server&bits=64&release=latest
If wanted, the image data file should be streamed through the request body. The server will receive that data in chunks, buffering them to a properly secured temporary file, avoiding buffering all the data into memory. Server will then handle the upload of that data to the definitive store location, cleaning then the generated temporary file.
Alternatively, a x-image-meta-location header can be passed, if the file is already stored in some provided location. If this header is present, no body content can be passed in the request.
277 |
# File 'lib/image/server.rb', line 277 put '/images/:id', PutImage |