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
|
The main goal of a domain model is refactoring the logic around
|
||||||
object manipulation by splitting it to independent layers. Each
|
object manipulation by splitting it to independent layers. Each
|
||||||
subsequent layer wraps the previous one creating an "onion" structure,
|
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
|
of domain model is to use a composition instead of inheritance or
|
||||||
basic decoration while building an architecture. This provides
|
basic decoration while building an architecture. This provides
|
||||||
flexibility and transparency of an internal organization for a developer,
|
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
|
special ``proxy`` class. At first, operations are performed on the
|
||||||
upper layer, then they successively pass the control to the underlying
|
upper layer, then they successively pass the control to the underlying
|
||||||
layers.
|
layers.
|
||||||
|
|
||||||
The nesting of layers can be specified explicitly using a programmer
|
The nesting of layers can be specified explicitly using a programmer
|
||||||
interface Gateway or implicitly using ``helper`` classes. Nesting
|
interface Gateway or implicitly using ``helper`` classes. Nesting
|
||||||
may also depend on various conditions, skipping or adding additional
|
may also depend on various conditions, skipping or adding additional
|
||||||
@ -128,21 +129,21 @@ This example defines three classes:
|
|||||||
return sum(args)
|
return sum(args)
|
||||||
|
|
||||||
class LoggerProxy(object):
|
class LoggerProxy(object):
|
||||||
""""Class extends functionality by writing message to log"""
|
""""Class extends functionality by writing message to log."""
|
||||||
def __init__(self, base, logg):
|
def __init__(self, base, logg):
|
||||||
self.base = base
|
self.base = base
|
||||||
self.logg = logg
|
self.logg = logg
|
||||||
|
|
||||||
# Proxy to provide implicit access to inner layer
|
# Proxy to provide implicit access to inner layer.
|
||||||
msg = _create_property_proxy('msg')
|
msg = _create_property_proxy('msg')
|
||||||
|
|
||||||
def print_msg(self):
|
def print_msg(self):
|
||||||
# Write message to log and then pass the control to inner layer
|
# Write message to log and then pass the control to inner layer.
|
||||||
self.logg.write("Message %s has written to log") % self.msg
|
self.logg.write("Message %s has been written to the log") % self.msg
|
||||||
self.base.print_msg()
|
self.base.print_msg()
|
||||||
|
|
||||||
def sum_numbers(self, *args):
|
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)
|
return self.base.sum_numbers(*args)
|
||||||
|
|
||||||
class ValidatorProxy(object):
|
class ValidatorProxy(object):
|
||||||
@ -153,14 +154,14 @@ This example defines three classes:
|
|||||||
msg = _create_property_proxy('msg')
|
msg = _create_property_proxy('msg')
|
||||||
|
|
||||||
def print_msg(self):
|
def print_msg(self):
|
||||||
# There are no checks
|
# There are no checks.
|
||||||
self.base.print_msg()
|
self.base.print_msg()
|
||||||
|
|
||||||
def sum_numbers(self, *args):
|
def sum_numbers(self, *args):
|
||||||
# Validate input numbers and pass them next
|
# Validate input numbers and pass them further.
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if arg <= 0:
|
if arg <= 0:
|
||||||
return "Only positive numbers are supported"
|
return "Only positive numbers are supported."
|
||||||
return self.base.sum_numbers(*args)
|
return self.base.sum_numbers(*args)
|
||||||
|
|
||||||
Thus, the ``gateway`` method for the above example may look like:
|
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 {}
|
self.proxy_kwargs = proxy_kwargs or {}
|
||||||
|
|
||||||
def proxy(self, obj):
|
def proxy(self, obj):
|
||||||
"""Wrap an object"""
|
"""Wrap an object."""
|
||||||
if obj is None or self.proxy_class is None:
|
if obj is None or self.proxy_class is None:
|
||||||
return obj
|
return obj
|
||||||
return self.proxy_class(obj, **self.proxy_kwargs)
|
return self.proxy_class(obj, **self.proxy_kwargs)
|
||||||
|
|
||||||
def unproxy(self, obj):
|
def unproxy(self, obj):
|
||||||
"""Return object from inner layer"""
|
"""Return object from inner layer."""
|
||||||
if obj is None or self.proxy_class is None:
|
if obj is None or self.proxy_class is None:
|
||||||
return obj
|
return obj
|
||||||
return obj.base
|
return obj.base
|
||||||
@ -221,12 +222,12 @@ previous example. It specifies a ``BaseFactory`` class with a
|
|||||||
::
|
::
|
||||||
|
|
||||||
class BaseFactory(object):
|
class BaseFactory(object):
|
||||||
"""Simple factory to generate an object"""
|
"""Simple factory to generate an object."""
|
||||||
def generate(self):
|
def generate(self):
|
||||||
return Base()
|
return Base()
|
||||||
|
|
||||||
class LoggerFactory(object):
|
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):
|
def __init__(self, base, proxy_class=None, proxy_kwargs=None):
|
||||||
self.helper = Helper(proxy_class, proxy_kwargs)
|
self.helper = Helper(proxy_class, proxy_kwargs)
|
||||||
self.base = base
|
self.base = base
|
||||||
@ -236,7 +237,7 @@ previous example. It specifies a ``BaseFactory`` class with a
|
|||||||
return self.helper.proxy(self.base.generate())
|
return self.helper.proxy(self.base.generate())
|
||||||
|
|
||||||
class ValidatorFactory(object):
|
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):
|
def __init__(self, base, only_positive=True, proxy_class=None, proxy_kwargs=None):
|
||||||
self.helper = Helper(proxy_class, proxy_kwargs)
|
self.helper = Helper(proxy_class, proxy_kwargs)
|
||||||
self.base = base
|
self.base = base
|
||||||
@ -244,7 +245,7 @@ previous example. It specifies a ``BaseFactory`` class with a
|
|||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
if self.only_positive:
|
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.helper.proxy(self.base.generate())
|
||||||
return self.base.generate()
|
return self.base.generate()
|
||||||
|
|
||||||
|
@ -89,28 +89,28 @@ JSON-encoded mapping in the following format::
|
|||||||
|
|
||||||
.. note::
|
.. 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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
Filtering Images Lists
|
||||||
**********************
|
**********************
|
||||||
@ -164,13 +164,14 @@ These two resources also accept additional query parameters:
|
|||||||
|
|
||||||
* ``marker=ID``
|
* ``marker=ID``
|
||||||
|
|
||||||
An image identifier marker may be specified. When present only images which
|
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
|
occur after the identifier ``ID`` will be listed. (These are the images that
|
||||||
a `sort_key` later than that of the marker ``ID`` in the `sort_dir` direction.
|
have a `sort_key` later than that of the marker ``ID`` in the `sort_dir`
|
||||||
|
direction.)
|
||||||
|
|
||||||
* ``limit=LIMIT``
|
* ``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::
|
.. note::
|
||||||
|
|
||||||
@ -237,25 +238,25 @@ following shows an example of the HTTP headers returned from the above
|
|||||||
|
|
||||||
.. note::
|
.. 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
|
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'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
|
There may be multiple headers that begin with the prefix
|
||||||
`x-image-meta-property-`. These headers are free-form key/value pairs
|
`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
|
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
|
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
|
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
|
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
|
Retrieve Raw Image Data
|
||||||
@ -300,28 +301,28 @@ returned from the above ``GET`` request::
|
|||||||
|
|
||||||
.. note::
|
.. 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
|
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'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
|
There may be multiple headers that begin with the prefix
|
||||||
`x-image-meta-property-`. These headers are free-form key/value pairs
|
`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
|
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 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
|
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
|
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
|
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
|
The image data itself will be the body of the HTTP response returned
|
||||||
from the request, which will have content-type of
|
from the request, which will have content-type of
|
||||||
@ -355,7 +356,7 @@ Reserve a New Image
|
|||||||
|
|
||||||
We can also perform the activities described in `Add a New Image`_ using two
|
We can also perform the activities described in `Add a New Image`_ using two
|
||||||
separate calls to the Image API; the first to register the image metadata, and
|
separate calls to the Image API; the first to register the image metadata, and
|
||||||
the second to add the image disk data. This is known as "reserving" an image.
|
the second to add the image disk data. This is known as "reserving" an image.
|
||||||
|
|
||||||
The first call should be a ``POST`` to ``http://glance.example.com/v1/images``,
|
The first call should be a ``POST`` to ``http://glance.example.com/v1/images``,
|
||||||
which will result in a new image id being registered with a status of
|
which will result in a new image id being registered with a status 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.
|
When present, Glance will use the supplied identifier for the image.
|
||||||
If the identifier already exists in that Glance node, then a
|
If the identifier already exists in that Glance node, then a
|
||||||
**409 Conflict** will be returned by Glance. The value of the header
|
**409 Conflict** will be returned by Glance. The value of the header
|
||||||
must be an uuid in hexadecimal string notation
|
must be a uuid in hexadecimal string notation
|
||||||
(i.e. 71c675ab-d94f-49cd-a114-e12490b328d9).
|
(that is 71c675ab-d94f-49cd-a114-e12490b328d9).
|
||||||
|
|
||||||
When this header is *not* present, Glance will generate an identifier
|
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``
|
* ``x-image-meta-store``
|
||||||
|
|
||||||
This header is optional. Valid values are one of ``file``, ``s3``, ``rbd``,
|
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
|
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
|
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**.
|
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
|
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.
|
for more information.
|
||||||
|
|
||||||
* ``x-image-meta-disk_format``
|
* ``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
|
``aki``, ``ari``, ``ami``, ``raw``, ``iso``, ``vhd``, ``vdi``, ``qcow2``, or
|
||||||
``vmdk``.
|
``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``
|
* ``x-image-meta-container_format``
|
||||||
|
|
||||||
This header is required, unless reserving an image. Valid values are one of
|
This header is required, unless reserving an image. Valid values are one of
|
||||||
``aki``, ``ari``, ``ami``, ``bare``, or ``ovf``.
|
``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``
|
* ``x-image-meta-size``
|
||||||
|
|
||||||
@ -444,11 +445,11 @@ The list of metadata headers that Glance accepts are listed below.
|
|||||||
|
|
||||||
* ``x-image-meta-checksum``
|
* ``x-image-meta-checksum``
|
||||||
|
|
||||||
This header is optional. When present it shall be the expected **MD5**
|
This header is optional. When present, it specifies the **MD5** checksum
|
||||||
checksum of the image file data.
|
of the image file data.
|
||||||
|
|
||||||
When present, Glance will verify the checksum generated from the backend
|
When present, Glance will verify the checksum generated from the back-end
|
||||||
store when storing your image against this value and return a
|
store while storing your image against this value and return a
|
||||||
**400 Bad Request** if the values do not match.
|
**400 Bad Request** if the values do not match.
|
||||||
|
|
||||||
* ``x-image-meta-is_public``
|
* ``x-image-meta-is_public``
|
||||||
@ -456,7 +457,7 @@ The list of metadata headers that Glance accepts are listed below.
|
|||||||
This header is optional.
|
This header is optional.
|
||||||
|
|
||||||
When Glance finds the string "true" (case-insensitive), the image is marked as
|
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.
|
the disk image from Glance.
|
||||||
|
|
||||||
When not present, the image is assumed to be *not public* and owned by
|
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``
|
* ``x-image-meta-min_ram``
|
||||||
|
|
||||||
This header is optional. When present it shall be the expected minimum ram
|
This header is optional. When present, it specifies the minimum amount of
|
||||||
required in megabytes to run this image on a server.
|
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``
|
* ``x-image-meta-min_disk``
|
||||||
|
|
||||||
This header is optional. When present it shall be the expected minimum disk
|
This header is optional. When present, it specifies the expected minimum disk
|
||||||
space required in gigabytes to run this image on a server.
|
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``
|
* ``x-image-meta-owner``
|
||||||
|
|
||||||
@ -482,7 +484,7 @@ The list of metadata headers that Glance accepts are listed below.
|
|||||||
|
|
||||||
Glance normally sets the owner of an image to be the tenant or user
|
Glance normally sets the owner of an image to be the tenant or user
|
||||||
(depending on the "owner_is_tenant" configuration option) of the
|
(depending on the "owner_is_tenant" configuration option) of the
|
||||||
authenticated user issuing the request. However, if the authenticated user
|
authenticated user issuing the request. However, if the authenticated user
|
||||||
has the Admin role, this default may be overridden by setting this header to
|
has the Admin role, this default may be overridden by setting this header to
|
||||||
null or to a string identifying the owner of the image.
|
null or to a string identifying the owner of the image.
|
||||||
|
|
||||||
@ -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
|
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,
|
``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
|
lower-cased string following the prefix ``x-image-meta-property-`` with dashes
|
||||||
and punctuation replaced with underscores.
|
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
|
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.
|
image in Glance.
|
||||||
|
|
||||||
There is no limit on the number of free-form key/value attributes that can
|
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
|
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
|
size of all the HTTP headers sent in a request will effectively limit the
|
||||||
of image properties.
|
number of image properties.
|
||||||
|
|
||||||
|
|
||||||
Update an Image
|
Update an Image
|
||||||
***************
|
***************
|
||||||
|
|
||||||
Glance will view as image metadata any HTTP header that it receives in a
|
Glance will consider any HTTP header that it receives in a ``PUT`` request
|
||||||
``PUT`` request where the header key is prefixed with the strings
|
as an instance of image metadata. In this case, the header key should be
|
||||||
``x-image-meta-`` and ``x-image-meta-property-``.
|
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
|
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
|
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
|
already has data associated with it (for example, it is not in the ``queued``
|
||||||
including a request body will result in a **409 Conflict** exception.
|
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
|
On success, the ``PUT`` request will return the image metadata encoded as HTTP
|
||||||
headers.
|
headers.
|
||||||
@ -530,21 +533,21 @@ List Image Memberships
|
|||||||
|
|
||||||
We want to see a list of the other system tenants (or users, if
|
We want to see a list of the other system tenants (or users, if
|
||||||
"owner_is_tenant" is False) that may access a given virtual machine image that
|
"owner_is_tenant" is False) that may access a given virtual machine image that
|
||||||
the Glance server knows about. We take the `uri` field of the image data,
|
the Glance server knows about. We take the `uri` field of the image data,
|
||||||
append ``/members`` to it, and issue a ``GET`` request on the resulting URL.
|
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
|
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
|
first image returned, we can issue a ``GET`` request to the Glance
|
||||||
server for
|
server for
|
||||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``
|
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``.
|
||||||
. What we will get back is JSON data such as the following::
|
And we will get back JSON data such as the following::
|
||||||
|
|
||||||
{'members': [
|
{'members': [
|
||||||
{'member_id': 'tenant1',
|
{'member_id': 'tenant1',
|
||||||
'can_share': false}
|
'can_share': false}
|
||||||
...]}
|
...]}
|
||||||
|
|
||||||
The `member_id` field identifies a tenant with which the image is shared. If
|
The `member_id` field identifies a tenant with which the image is shared. If
|
||||||
that tenant is authorized to further share the image, the `can_share` field is
|
that tenant is authorized to further share the image, the `can_share` field is
|
||||||
`true`.
|
`true`.
|
||||||
|
|
||||||
@ -552,8 +555,8 @@ that tenant is authorized to further share the image, the `can_share` field is
|
|||||||
List Shared Images
|
List Shared Images
|
||||||
******************
|
******************
|
||||||
|
|
||||||
We want to see a list of images which are shared with a given tenant. We issue
|
We want to see a list of images which are shared with a given tenant. We issue
|
||||||
a ``GET`` request to ``http://glance.example.com/v1/shared-images/tenant1``. We
|
a ``GET`` request to ``http://glance.example.com/v1/shared-images/tenant1``. We
|
||||||
will get back JSON data such as the following::
|
will get back JSON data such as the following::
|
||||||
|
|
||||||
{'shared_images': [
|
{'shared_images': [
|
||||||
@ -562,17 +565,17 @@ will get back JSON data such as the following::
|
|||||||
...]}
|
...]}
|
||||||
|
|
||||||
The `image_id` field identifies an image shared with the tenant named by
|
The `image_id` field identifies an image shared with the tenant named by
|
||||||
*member_id*. If the tenant is authorized to further share the image, the
|
*member_id*. If the tenant is authorized to further share the image, the
|
||||||
`can_share` field is `true`.
|
`can_share` field is `true`.
|
||||||
|
|
||||||
|
|
||||||
Add a Member to an Image
|
Add a Member to an Image
|
||||||
************************
|
************************
|
||||||
|
|
||||||
We want to authorize a tenant to access a private image. We issue a ``PUT``
|
We want to authorize a tenant to access a private image. We issue a ``PUT``
|
||||||
request to
|
request to
|
||||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members/tenant1``
|
``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
|
With no body, this will add the membership to the image, leaving existing
|
||||||
memberships unmodified and defaulting new memberships to have `can_share`
|
memberships unmodified and defaulting new memberships to have `can_share`
|
||||||
set to `false`. We may also optionally attach a body of the following form::
|
set to `false`. We may also optionally attach a body of the following form::
|
||||||
|
|
||||||
@ -581,14 +584,14 @@ set to `false`. We may also optionally attach a body of the following form::
|
|||||||
}
|
}
|
||||||
|
|
||||||
If such a body is provided, both existing and new memberships will have
|
If such a body is provided, both existing and new memberships will have
|
||||||
`can_share` set to the provided value (either `true` or `false`). This query
|
`can_share` set to the provided value (either `true` or `false`). This query
|
||||||
will return a 204 ("No Content") status code.
|
will return a 204 ("No Content") status code.
|
||||||
|
|
||||||
|
|
||||||
Remove a Member from an Image
|
Remove a Member from an Image
|
||||||
*****************************
|
*****************************
|
||||||
|
|
||||||
We want to revoke a tenant's right to access a private image. We issue a
|
We want to revoke a tenant's right to access a private image. We issue a
|
||||||
``DELETE`` request to ``http://glance.example.com/v1/images/1/members/tenant1``.
|
``DELETE`` request to ``http://glance.example.com/v1/images/1/members/tenant1``.
|
||||||
This query will return a 204 ("No Content") status code.
|
This query will return a 204 ("No Content") status code.
|
||||||
|
|
||||||
@ -596,7 +599,7 @@ This query will return a 204 ("No Content") status code.
|
|||||||
Replace a Membership List for an Image
|
Replace a Membership List for an Image
|
||||||
**************************************
|
**************************************
|
||||||
|
|
||||||
The full membership list for a given image may be replaced. We issue a ``PUT``
|
The full membership list for a given image may be replaced. We issue a ``PUT``
|
||||||
request to
|
request to
|
||||||
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``
|
``http://glance.example.com/v1/images/71c675ab-d94f-49cd-a114-e12490b328d9/members``
|
||||||
with a body of the following form::
|
with a body of the following form::
|
||||||
@ -608,19 +611,20 @@ with a body of the following form::
|
|||||||
|
|
||||||
All existing memberships which are not named in the replacement body are
|
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
|
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
|
specified. (The `can_share` setting may be omitted, which will cause that
|
||||||
setting to remain unchanged in the existing memberships.) All new memberships
|
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
|
Image Membership Changes in Version 2.0
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Version 2.0 of the Images API eliminates the ``can_share`` attribute of image
|
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.
|
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
|
In version 2.0, image members have a ``status`` attribute that reflects
|
||||||
image should be treated with respect to that image member's image list.
|
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``,
|
* The ``status`` attribute may have one of three values: ``pending``,
|
||||||
``accepted``, or ``rejected``.
|
``accepted``, or ``rejected``.
|
||||||
@ -630,8 +634,8 @@ image should be treated with respect to that image member's image list.
|
|||||||
|
|
||||||
* Only an image member may change his/her own membership status.
|
* Only an image member may change his/her own membership status.
|
||||||
|
|
||||||
* Only an image owner may create members on an image. The status of a newly
|
* Only an image owner may create members on an image. The status of a newly
|
||||||
created image member is ``pending``. The image owner cannot change the
|
created image member is ``pending``. The image owner cannot change the
|
||||||
status of a member.
|
status of a member.
|
||||||
|
|
||||||
|
|
||||||
@ -667,12 +671,12 @@ New API Calls
|
|||||||
|
|
||||||
{ "status": "<STATUS_VALUE>" }
|
{ "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.
|
The {memberId} is the tenant ID of the image member.
|
||||||
|
|
||||||
|
|
||||||
API Message Localization
|
API Message Localization
|
||||||
---------------------------------------
|
------------------------
|
||||||
Glance supports HTTP message localization. For example, an HTTP client can
|
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
|
receive API messages in Chinese even if the locale language of the server is
|
||||||
English.
|
English.
|
||||||
@ -680,8 +684,8 @@ English.
|
|||||||
How to use it
|
How to use it
|
||||||
*************
|
*************
|
||||||
To receive localized API messages, the HTTP client needs to specify the
|
To receive localized API messages, the HTTP client needs to specify the
|
||||||
**Accept-Language** header to indicate the language to use to translate the
|
**Accept-Language** header to indicate the language that will translate the
|
||||||
message. For more info about Accept-Language, please refer http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
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::
|
A typical curl API request will be like below::
|
||||||
|
|
||||||
@ -707,5 +711,5 @@ Then the response will be like the following::
|
|||||||
</html>
|
</html>
|
||||||
|
|
||||||
.. note::
|
.. 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.
|
the target Glance server.
|
||||||
|
Loading…
Reference in New Issue
Block a user