Merge "[Glance Developer Guide] Grammar edits"
This commit is contained in:
commit
6681908e17
@ -21,7 +21,7 @@ Domain model
|
||||
The main goal of a domain model is refactoring the logic around
|
||||
object manipulation by splitting it to independent layers. Each
|
||||
subsequent layer wraps the previous one creating an "onion" structure,
|
||||
thus realizing a design pattern called "Decorator". The main feature
|
||||
thus realizing a design pattern called "Decorator." The main feature
|
||||
of domain model is to use a composition instead of inheritance or
|
||||
basic decoration while building an architecture. This provides
|
||||
flexibility and transparency of an internal organization for a developer,
|
||||
@ -35,6 +35,7 @@ Each layer defines its own operations’ implementation through a
|
||||
special ``proxy`` class. At first, operations are performed on the
|
||||
upper layer, then they successively pass the control to the underlying
|
||||
layers.
|
||||
|
||||
The nesting of layers can be specified explicitly using a programmer
|
||||
interface Gateway or implicitly using ``helper`` classes. Nesting
|
||||
may also depend on various conditions, skipping or adding additional
|
||||
@ -128,21 +129,21 @@ This example defines three classes:
|
||||
return sum(args)
|
||||
|
||||
class LoggerProxy(object):
|
||||
""""Class extends functionality by writing message to log"""
|
||||
""""Class extends functionality by writing message to log."""
|
||||
def __init__(self, base, logg):
|
||||
self.base = base
|
||||
self.logg = logg
|
||||
|
||||
# Proxy to provide implicit access to inner layer
|
||||
# Proxy to provide implicit access to inner layer.
|
||||
msg = _create_property_proxy('msg')
|
||||
|
||||
def print_msg(self):
|
||||
# Write message to log and then pass the control to inner layer
|
||||
self.logg.write("Message %s has written to log") % self.msg
|
||||
# Write message to log and then pass the control to inner layer.
|
||||
self.logg.write("Message %s has been written to the log") % self.msg
|
||||
self.base.print_msg()
|
||||
|
||||
def sum_numbers(self, *args):
|
||||
# Nothing to do here. Just pass the control to the next layer
|
||||
# Nothing to do here. Just pass the control to the next layer.
|
||||
return self.base.sum_numbers(*args)
|
||||
|
||||
class ValidatorProxy(object):
|
||||
@ -153,14 +154,14 @@ This example defines three classes:
|
||||
msg = _create_property_proxy('msg')
|
||||
|
||||
def print_msg(self):
|
||||
# There are no checks
|
||||
# There are no checks.
|
||||
self.base.print_msg()
|
||||
|
||||
def sum_numbers(self, *args):
|
||||
# Validate input numbers and pass them next
|
||||
# Validate input numbers and pass them further.
|
||||
for arg in args:
|
||||
if arg <= 0:
|
||||
return "Only positive numbers are supported"
|
||||
return "Only positive numbers are supported."
|
||||
return self.base.sum_numbers(*args)
|
||||
|
||||
Thus, the ``gateway`` method for the above example may look like:
|
||||
@ -200,13 +201,13 @@ has the following form:
|
||||
self.proxy_kwargs = proxy_kwargs or {}
|
||||
|
||||
def proxy(self, obj):
|
||||
"""Wrap an object"""
|
||||
"""Wrap an object."""
|
||||
if obj is None or self.proxy_class is None:
|
||||
return obj
|
||||
return self.proxy_class(obj, **self.proxy_kwargs)
|
||||
|
||||
def unproxy(self, obj):
|
||||
"""Return object from inner layer"""
|
||||
"""Return object from inner layer."""
|
||||
if obj is None or self.proxy_class is None:
|
||||
return obj
|
||||
return obj.base
|
||||
@ -221,12 +222,12 @@ previous example. It specifies a ``BaseFactory`` class with a
|
||||
::
|
||||
|
||||
class BaseFactory(object):
|
||||
"""Simple factory to generate an object"""
|
||||
"""Simple factory to generate an object."""
|
||||
def generate(self):
|
||||
return Base()
|
||||
|
||||
class LoggerFactory(object):
|
||||
"""Proxy class to add logging functionality"""
|
||||
"""Proxy class to add logging functionality."""
|
||||
def __init__(self, base, proxy_class=None, proxy_kwargs=None):
|
||||
self.helper = Helper(proxy_class, proxy_kwargs)
|
||||
self.base = base
|
||||
@ -236,7 +237,7 @@ previous example. It specifies a ``BaseFactory`` class with a
|
||||
return self.helper.proxy(self.base.generate())
|
||||
|
||||
class ValidatorFactory(object):
|
||||
"""Proxy class to add validation"""
|
||||
"""Proxy class to add validation."""
|
||||
def __init__(self, base, only_positive=True, proxy_class=None, proxy_kwargs=None):
|
||||
self.helper = Helper(proxy_class, proxy_kwargs)
|
||||
self.base = base
|
||||
@ -244,7 +245,7 @@ previous example. It specifies a ``BaseFactory`` class with a
|
||||
|
||||
def generate(self):
|
||||
if self.only_positive:
|
||||
# Wrap in ValidatorProxy if it's required
|
||||
# Wrap in ValidatorProxy if required.
|
||||
return self.helper.proxy(self.base.generate())
|
||||
return self.base.generate()
|
||||
|
||||
|
@ -89,28 +89,28 @@ JSON-encoded mapping in the following format::
|
||||
|
||||
.. note::
|
||||
|
||||
All timestamps returned are in UTC
|
||||
All timestamps returned are in UTC.
|
||||
|
||||
The `updated_at` timestamp is the timestamp when an image's metadata
|
||||
was last updated, not its image data, as all image data is immutable
|
||||
once stored in Glance
|
||||
once stored in Glance.
|
||||
|
||||
The `properties` field is a mapping of free-form key/value pairs that
|
||||
have been saved with the image metadata
|
||||
have been saved with the image metadata.
|
||||
|
||||
The `checksum` field is an MD5 checksum of the image file data
|
||||
The `checksum` field is an MD5 checksum of the image file data.
|
||||
|
||||
The `is_public` field is a boolean indicating whether the image is
|
||||
publicly available
|
||||
publicly available.
|
||||
|
||||
The `min_ram` field is an integer specifying the minimum amount of
|
||||
ram needed to run this image on an instance, in megabytes
|
||||
RAM needed to run this image on an instance, in megabytes.
|
||||
|
||||
The `min_disk` field is an integer specifying the minimum amount of
|
||||
disk space needed to run this image on an instance, in gigabytes
|
||||
disk space needed to run this image on an instance, in gigabytes.
|
||||
|
||||
The `owner` field is a string which may either be null or which will
|
||||
indicate the owner of the image
|
||||
indicate the owner of the image.
|
||||
|
||||
Filtering Images Lists
|
||||
**********************
|
||||
@ -164,13 +164,14 @@ These two resources also accept additional query parameters:
|
||||
|
||||
* ``marker=ID``
|
||||
|
||||
An image identifier marker may be specified. When present only images which
|
||||
occur after the identifier ``ID`` will be listed, i.e. the images which have
|
||||
a `sort_key` later than that of the marker ``ID`` in the `sort_dir` direction.
|
||||
An image identifier marker may be specified. When present, only images which
|
||||
occur after the identifier ``ID`` will be listed. (These are the images that
|
||||
have a `sort_key` later than that of the marker ``ID`` in the `sort_dir`
|
||||
direction.)
|
||||
|
||||
* ``limit=LIMIT``
|
||||
|
||||
When present the maximum number of results returned will not exceed ``LIMIT``.
|
||||
When present, the maximum number of results returned will not exceed ``LIMIT``.
|
||||
|
||||
.. note::
|
||||
|
||||
@ -237,25 +238,25 @@ following shows an example of the HTTP headers returned from the above
|
||||
|
||||
.. note::
|
||||
|
||||
All timestamps returned are in UTC
|
||||
All timestamps returned are in UTC.
|
||||
|
||||
The `x-image-meta-updated_at` timestamp is the timestamp when an
|
||||
image's metadata was last updated, not its image data, as all
|
||||
image data is immutable once stored in Glance
|
||||
image data is immutable once stored in Glance.
|
||||
|
||||
There may be multiple headers that begin with the prefix
|
||||
`x-image-meta-property-`. These headers are free-form key/value pairs
|
||||
that have been saved with the image metadata. The key is the string
|
||||
after `x-image-meta-property-` and the value is the value of the header
|
||||
after `x-image-meta-property-` and the value is the value of the header.
|
||||
|
||||
The response's `ETag` header will always be equal to the
|
||||
`x-image-meta-checksum` value
|
||||
`x-image-meta-checksum` value.
|
||||
|
||||
The response's `x-image-meta-is_public` value is a boolean indicating
|
||||
whether the image is publicly available
|
||||
whether the image is publicly available.
|
||||
|
||||
The response's `x-image-meta-owner` value is a string which may either
|
||||
be null or which will indicate the owner of the image
|
||||
be null or which will indicate the owner of the image.
|
||||
|
||||
|
||||
Retrieve Raw Image Data
|
||||
@ -300,28 +301,28 @@ returned from the above ``GET`` request::
|
||||
|
||||
.. note::
|
||||
|
||||
All timestamps returned are in UTC
|
||||
All timestamps returned are in UTC.
|
||||
|
||||
The `x-image-meta-updated_at` timestamp is the timestamp when an
|
||||
image's metadata was last updated, not its image data, as all
|
||||
image data is immutable once stored in Glance
|
||||
image data is immutable once stored in Glance.
|
||||
|
||||
There may be multiple headers that begin with the prefix
|
||||
`x-image-meta-property-`. These headers are free-form key/value pairs
|
||||
that have been saved with the image metadata. The key is the string
|
||||
after `x-image-meta-property-` and the value is the value of the header
|
||||
after `x-image-meta-property-` and the value is the value of the header.
|
||||
|
||||
The response's `Content-Length` header shall be equal to the value of
|
||||
the `x-image-meta-size` header
|
||||
the `x-image-meta-size` header.
|
||||
|
||||
The response's `ETag` header will always be equal to the
|
||||
`x-image-meta-checksum` value
|
||||
`x-image-meta-checksum` value.
|
||||
|
||||
The response's `x-image-meta-is_public` value is a boolean indicating
|
||||
whether the image is publicly available
|
||||
whether the image is publicly available.
|
||||
|
||||
The response's `x-image-meta-owner` value is a string which may either
|
||||
be null or which will indicate the owner of the image
|
||||
be null or which will indicate the owner of the image.
|
||||
|
||||
The image data itself will be the body of the HTTP response returned
|
||||
from the request, which will have content-type of
|
||||
@ -396,23 +397,23 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
When present, Glance will use the supplied identifier for the image.
|
||||
If the identifier already exists in that Glance node, then a
|
||||
**409 Conflict** will be returned by Glance. The value of the header
|
||||
must be an uuid in hexadecimal string notation
|
||||
(i.e. 71c675ab-d94f-49cd-a114-e12490b328d9).
|
||||
must be a uuid in hexadecimal string notation
|
||||
(that is 71c675ab-d94f-49cd-a114-e12490b328d9).
|
||||
|
||||
When this header is *not* present, Glance will generate an identifier
|
||||
for the image and return this identifier in the response (see below)
|
||||
for the image and return this identifier in the response (see below).
|
||||
|
||||
* ``x-image-meta-store``
|
||||
|
||||
This header is optional. Valid values are one of ``file``, ``s3``, ``rbd``,
|
||||
``swift``, ``cinder``, ``gridfs``, ``sheepdog`` or ``vsphere``
|
||||
``swift``, ``cinder``, ``gridfs``, ``sheepdog`` or ``vsphere``.
|
||||
|
||||
When present, Glance will attempt to store the disk image data in the
|
||||
backing store indicated by the value of the header. If the Glance node
|
||||
does not support the backing store, Glance will return a **400 Bad Request**.
|
||||
|
||||
When not present, Glance will store the disk image data in the backing
|
||||
store that is marked default. See the configuration option ``default_store``
|
||||
store that is marked as default. See the configuration option ``default_store``
|
||||
for more information.
|
||||
|
||||
* ``x-image-meta-disk_format``
|
||||
@ -421,14 +422,14 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
``aki``, ``ari``, ``ami``, ``raw``, ``iso``, ``vhd``, ``vdi``, ``qcow2``, or
|
||||
``vmdk``.
|
||||
|
||||
For more information, see :doc:`About Disk and Container Formats <formats>`
|
||||
For more information, see :doc:`About Disk and Container Formats <formats>`.
|
||||
|
||||
* ``x-image-meta-container_format``
|
||||
|
||||
This header is required, unless reserving an image. Valid values are one of
|
||||
``aki``, ``ari``, ``ami``, ``bare``, or ``ovf``.
|
||||
|
||||
For more information, see :doc:`About Disk and Container Formats <formats>`
|
||||
For more information, see :doc:`About Disk and Container Formats <formats>`.
|
||||
|
||||
* ``x-image-meta-size``
|
||||
|
||||
@ -444,11 +445,11 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
|
||||
* ``x-image-meta-checksum``
|
||||
|
||||
This header is optional. When present it shall be the expected **MD5**
|
||||
checksum of the image file data.
|
||||
This header is optional. When present, it specifies the **MD5** checksum
|
||||
of the image file data.
|
||||
|
||||
When present, Glance will verify the checksum generated from the backend
|
||||
store when storing your image against this value and return a
|
||||
When present, Glance will verify the checksum generated from the back-end
|
||||
store while storing your image against this value and return a
|
||||
**400 Bad Request** if the values do not match.
|
||||
|
||||
* ``x-image-meta-is_public``
|
||||
@ -456,7 +457,7 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
This header is optional.
|
||||
|
||||
When Glance finds the string "true" (case-insensitive), the image is marked as
|
||||
a public image, meaning that any user may view its metadata and may read
|
||||
a public one, meaning that any user may view its metadata and may read
|
||||
the disk image from Glance.
|
||||
|
||||
When not present, the image is assumed to be *not public* and owned by
|
||||
@ -464,17 +465,18 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
|
||||
* ``x-image-meta-min_ram``
|
||||
|
||||
This header is optional. When present it shall be the expected minimum ram
|
||||
required in megabytes to run this image on a server.
|
||||
This header is optional. When present, it specifies the minimum amount of
|
||||
RAM in megabytes required to run this image on a server.
|
||||
|
||||
When not present, the image is assumed to have a minimum ram requirement of 0.
|
||||
When not present, the image is assumed to have a minimum RAM requirement of 0.
|
||||
|
||||
* ``x-image-meta-min_disk``
|
||||
|
||||
This header is optional. When present it shall be the expected minimum disk
|
||||
space required in gigabytes to run this image on a server.
|
||||
This header is optional. When present, it specifies the expected minimum disk
|
||||
space in gigabytes required to run this image on a server.
|
||||
|
||||
When not present, the image is assumed to have a minimum disk space requirement of 0.
|
||||
When not present, the image is assumed to have a minimum disk space
|
||||
requirement of 0.
|
||||
|
||||
* ``x-image-meta-owner``
|
||||
|
||||
@ -490,7 +492,7 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
|
||||
When Glance receives any HTTP header whose key begins with the string prefix
|
||||
``x-image-meta-property-``, Glance adds the key and value to a set of custom,
|
||||
free-form image properties stored with the image. The key is the
|
||||
free-form image properties stored with the image. The key is a
|
||||
lower-cased string following the prefix ``x-image-meta-property-`` with dashes
|
||||
and punctuation replaced with underscores.
|
||||
|
||||
@ -498,26 +500,27 @@ The list of metadata headers that Glance accepts are listed below.
|
||||
|
||||
x-image-meta-property-distro Ubuntu 10.10
|
||||
|
||||
Then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the
|
||||
then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the
|
||||
image in Glance.
|
||||
|
||||
There is no limit on the number of free-form key/value attributes that can
|
||||
be attached to the image. However, keep in mind that the 8K limit on the
|
||||
size of all HTTP headers sent in a request will effectively limit the number
|
||||
of image properties.
|
||||
size of all the HTTP headers sent in a request will effectively limit the
|
||||
number of image properties.
|
||||
|
||||
|
||||
Update an Image
|
||||
***************
|
||||
|
||||
Glance will view as image metadata any HTTP header that it receives in a
|
||||
``PUT`` request where the header key is prefixed with the strings
|
||||
``x-image-meta-`` and ``x-image-meta-property-``.
|
||||
Glance will consider any HTTP header that it receives in a ``PUT`` request
|
||||
as an instance of image metadata. In this case, the header key should be
|
||||
prefixed with the strings ``x-image-meta-`` and ``x-image-meta-property-``.
|
||||
|
||||
If an image was previously reserved, and thus is in the ``queued`` state, then
|
||||
image data can be added by including it as the request body. If the image
|
||||
already as data associated with it (e.g. not in the ``queued`` state), then
|
||||
including a request body will result in a **409 Conflict** exception.
|
||||
already has data associated with it (for example, it is not in the ``queued``
|
||||
state), then including a request body will result in a **409 Conflict**
|
||||
exception.
|
||||
|
||||
On success, the ``PUT`` request will return the image metadata encoded as HTTP
|
||||
headers.
|
||||
@ -536,8 +539,8 @@ append ``/members`` to it, and issue a ``GET`` request on the resulting URL.
|
||||
Continuing from the example above, in order to get the memberships for the
|
||||
first image returned, we can issue a ``GET`` request to the Glance
|
||||
server for
|
||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``
|
||||
. What we will get back is JSON data such as the following::
|
||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``.
|
||||
And we will get back JSON data such as the following::
|
||||
|
||||
{'members': [
|
||||
{'member_id': 'tenant1',
|
||||
@ -571,8 +574,8 @@ Add a Member to an Image
|
||||
|
||||
We want to authorize a tenant to access a private image. We issue a ``PUT``
|
||||
request to
|
||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members/tenant1``
|
||||
. With no body, this will add the membership to the image, leaving existing
|
||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members/tenant1``.
|
||||
With no body, this will add the membership to the image, leaving existing
|
||||
memberships unmodified and defaulting new memberships to have `can_share`
|
||||
set to `false`. We may also optionally attach a body of the following form::
|
||||
|
||||
@ -610,7 +613,8 @@ All existing memberships which are not named in the replacement body are
|
||||
removed, and those which are named have their `can_share` settings changed as
|
||||
specified. (The `can_share` setting may be omitted, which will cause that
|
||||
setting to remain unchanged in the existing memberships.) All new memberships
|
||||
will be created, with `can_share` defaulting to `false` if it is not specified.
|
||||
will be created, with `can_share` defaulting to `false` unless it is specified
|
||||
otherwise.
|
||||
|
||||
|
||||
Image Membership Changes in Version 2.0
|
||||
@ -619,8 +623,8 @@ Image Membership Changes in Version 2.0
|
||||
Version 2.0 of the Images API eliminates the ``can_share`` attribute of image
|
||||
membership. In the version 2.0 model, image sharing is not transitive.
|
||||
|
||||
In version 2.0, image members have a ``status`` attribute that reflects how the
|
||||
image should be treated with respect to that image member's image list.
|
||||
In version 2.0, image members have a ``status`` attribute that reflects
|
||||
how the image should be treated with respect to that image member's image-list.
|
||||
|
||||
* The ``status`` attribute may have one of three values: ``pending``,
|
||||
``accepted``, or ``rejected``.
|
||||
@ -667,12 +671,12 @@ New API Calls
|
||||
|
||||
{ "status": "<STATUS_VALUE>" }
|
||||
|
||||
where <STATUS_VALUE> is one of ``pending``, ``accepted``, or ``rejected``.
|
||||
where <STATUS_VALUE> is ``pending``, ``accepted``, or ``rejected``.
|
||||
The {memberId} is the tenant ID of the image member.
|
||||
|
||||
|
||||
API Message Localization
|
||||
---------------------------------------
|
||||
------------------------
|
||||
Glance supports HTTP message localization. For example, an HTTP client can
|
||||
receive API messages in Chinese even if the locale language of the server is
|
||||
English.
|
||||
@ -680,8 +684,8 @@ English.
|
||||
How to use it
|
||||
*************
|
||||
To receive localized API messages, the HTTP client needs to specify the
|
||||
**Accept-Language** header to indicate the language to use to translate the
|
||||
message. For more info about Accept-Language, please refer http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
**Accept-Language** header to indicate the language that will translate the
|
||||
message. For more information about Accept-Language, please refer to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
|
||||
A typical curl API request will be like below::
|
||||
|
||||
@ -707,5 +711,5 @@ Then the response will be like the following::
|
||||
</html>
|
||||
|
||||
.. note::
|
||||
Be sure there is the language package under /usr/share/locale-langpack/ on
|
||||
Make sure to have a language package under /usr/share/locale-langpack/ on
|
||||
the target Glance server.
|
||||
|
Loading…
Reference in New Issue
Block a user