Commit Graph

90 Commits

Author SHA1 Message Date
Pranali Deore 8c04d19e88 Enabled new defaults and scope checks by default
Enabling the enforce scope and new defaults by default in glance

Related blueprint secure-rbac

Change-Id: I0808dc0b1b34b527e38aa137c1dd25e1fc06409f
2023-02-16 11:11:31 +00:00
Pierre-Samuel Le Stang 480ea3825f Implement glance-download internal plugin
Add a new import method called glance-download
that implements a glance to glance download in
a multi-region cloud with a federated Keystone.

This method will copy the image data and
selected metadata to the target glance, checking
that the downloaded size match the "size" image
attribute in the source glance.

Implements: blueprint glance-download-import
Co-Authored-By: Victor Coutellier <victor.coutellier@gmail.com>
Change-Id: Ic51c5fd87caf04d38aeaf758ad2d0e2f28098e4d
2022-08-23 08:26:52 -07:00
Mridula Joshi 2a9a4c8e0e Fix overwriting of existing tags while creating new tags
It was observed that md-tag-create-multiple
(/v2/metadefs/namespaces/{namespace_name}/tags) API overwrites
existing tags for specified namespace rather than creating new one
in addition to the existing tags.
This patch resolves the issue by introducing a header 'X-Openstack-Append'
which on being True will append the new tags to existing ones and
if False will continue to overwrite the tags.

Implements: blueprint append-tags
Closes-Bug: #1939169
Change-Id: I29448746b14c542e5fbf0283011968ae1516642e
2022-02-16 05:45:06 +00:00
Stephen Finucane 87ba56161b Remove six.moves.urllib usage
Change-Id: I71be65ef7b8f710e9317419d7b38559b39f461b0
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2022-01-27 14:54:05 +00:00
Dan Smith ba37ea3227 Check get_image(s) in the API
This includes a change to catch Forbidden and convert to NotFound.
The previous Forbidden handler was not only correct (it shoud hide
the permissions error with "not found") but it was actually dead code,
since the DB was performing its own checks and would never raise
Forbidden.

This also includes a change of the default policy for get_images
to include the other states, like get_image does. I think this was
just an oversight in the original RBAC patches, which didn't matter
because they weren't really being honored strictly.

Partially implements: blueprint policy-refactor

Change-Id: I70100cd7f01da803e9740cea1f7ce7ae18ad6919
2021-08-04 07:56:05 -07:00
Dan Smith 41e1cecbe6 Distributed image import
This implements distributed image import support, which addresses
the problem when one API worker has staged the image and another
receives the import request.

The general approach is that when a worker stages the image, it
records its self-reference URL in the image's extra_properties.  When
the import request comes in, any other host will proxy that HTTP
request direct to the original host instead of trying to do the import
itself.

Implements: blueprint distributed-image-import

Change-Id: I12daccb43c535b579c22f9d0742039b2ab42e929
2021-03-02 11:52:12 -08:00
Dan Smith b019765668 Inspect upload/import stream and set virtual_size
If we are processing a disk_format that we know about, wrap the
data pipeline with the format inspector and set virtual_size
after upload is complete.

Related to blueprint calculate-virtual-size

Change-Id: I25cd3cde94fefaa5d8ac72f10a075fe34a5df7bf
2020-08-05 08:42:04 -07:00
Sean McGinnis 94b0876429 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I44e7b6f76e2d12f620ec602afc77ce11ba6b9d9a
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-20 15:07:00 +00:00
Dirk Mueller 595c1b17ff
Raise hacking to latest 2.0.0 release
We were capped at a very old version of hacking. Hacking itself caps the
various linters it uses to remain consistent, so our pep8 job was not
checking quite a bit that current versions have added.

This raises that limit to the latest to get up to the level of other
projects and addresses the errors the updated linters uncovered.

Change-Id: I89a9d73fbd59606a649e26077acebc5c42873d67
Co-authored-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-27 14:11:08 -05:00
Matt Riedemann 88a8ad7823 Fix DeprecationWarnings for RequestContext.tenant/user usage
RequestContext.tenant and user fields are deprecated in favor
of project_id and user_id respectively.

This change modifies the glance.context.RequestContext constructor
to transition usage of tenant/user to project_id/user_id until
all tests are moved over to the new attributes. Runtime usage of
the old fiels is updated.

To prevent new code from using the deprecated fields, a warnings
filter is added which will make tests fail if they hit code using
the old fields.

Co-Authored-By: Abhishek Kekane <akekane@redhat.com>
Change-Id: I351380840308a24769ece93abc6d1a9a6d6aa06f
2019-02-06 09:59:36 -05:00
Brian Rosmaita 0b24dbd620 Multihash implementation for Glance
Partially implements blueprint multihash.

Requires glance_store 0.26.1

Co-authored-by: Scott McClymont <scott.mcclymont@verizonwireless.com>
Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com>

Change-Id: Ib28ea1f6c431db6434dbab2a234018e82d5a6d1a
2018-07-31 21:28:38 -04:00
Zuul 040b7fad2b Merge "Delete data if image is deleted after staging call" 2018-02-08 19:47:12 +00:00
bhagyashris f5ae04b9f3 Implementation of Inject metadata properties
Implements the spec Inject metadata properties automatically
to non-admin images

This commit adds new task '_InjectImageMetadata' to inject
the metadata properties automatically to non-admin images
at the time of creation of images using newly introduce
'image-import' api in v2.

DocImpact

Implements: I6a7ed31d5fae677cbbc9a6f6053f79d3e9326561
Change-Id: I98be97c42f23b60a72d520aad5f6078a96372c59
2018-01-19 12:11:31 +05:30
bhagyashris 89feef0e2f Move 'upload_image' policy check to the controller
There are two methods to create images:-

Method A)
POST /v2/images
PUT /v2/images/{image_id}/file

Method B)
POST /v2/images
PUT /v2/images/{image_id}/stage
POST /v2/images/{image_id}/import

The traditional image upload API (PUT /v2/images/{image_id}/file)
uses 'upload_image' policy which is same for
Method B (POST /v2/images/{image_id}/import)
image-create-via-import(new API for image create) API.

The long term goal is to make users use method B to create images
and cross services to use Method A until changes are made to
use Method B.
To restrict normal users from using Method A to create images both
these APIs (/v2/images/{image_id}/file and /v2/images/{image_id}/import)
should have a distinct policy.

This patch move the 'upload_image' policy check from imge.set_data()
to the controller and not introduce any new policies at this point
for import API call (POST /v2/images/{image_id}/import)
on the theory that an operator can stop import by restricting the
'image_create' policy. And also this fix will not change the semantics
of the 'upload_image' policy from the operator perspective.

Closes-Bug: #1732141
Change-Id: Icc62add5f8d48549aac94c8058d66d6b77b56d41
2017-12-11 19:58:18 +05:30
Abhishek Kekane 7eb2fcc865 Delete data if image is deleted after staging call
Trying to delete image after staging call image gets deleted
from the database, but image data remains in the
staging area.

Deleted image data from the staging area if image_import is
enabled and image is in uploading state while deleting.

Closes-Bug: #1733289
Change-Id: I6ef1c05760a27a0b3620024003b49328c55f19a6
2017-11-28 03:55:00 +00:00
Brianna Poulos e8e0abdb1e Fix cursive named arguments
Change I08a32215d2ff40299919f859f8d18f5400641311 intruduced named
arguments when using cursive.

However, those named arguments were incorrect. See
b2aba64263/cursive/signature_utils.py (L175-L190)
for the correct arguments.

This commit fixes those named arguments, and updates the
fake_get_verifier method to reflect the get_verifier method in the
cursive library.

Change-Id: Ic5f1fe232b0553df8806278c9fc3b3445a0f9f1a
2016-09-09 13:05:16 +00:00
Dane Fichter 5afb5d33ed Use cursive for signature verification
This change removes the signature_utils module
from Glance and uses the cursive library, which
contains an identical module.

Change-Id: I80fcafa528b87a83b90ed7c0e4c0db9228852bc2
Depends-On: Ic3ffb6b318dc2ac6c9d3a60bed5198fd4d40e318
Partial-Bug: #1528349
2016-08-31 12:18:10 -07:00
Dane Fichter 1ad6cb60c9 Remove deprecated test utility
This change removes a utility which was
deprecated in Mitaka and scheduled for
removal in Newton.

TrivialFix

Change-Id: Ib3c72c46ba26c61980b4c96968c09fc791e596a6
2016-08-02 22:17:52 -04:00
yuyafei f9613c77fb Remove unused LOG to keep code clean
TrivialFix

Change-Id: Id1b19986c4a740a512ef4cb9615a727321be1654
2016-07-09 10:13:50 +08:00
Brianna Poulos 95ca43f30f Add sign-the-data signature verification
Per discussion on the mailing list [1] and the related nova
specification [2] it has been decided that the signature should be of
the image data directly, rather than of the glance MD5 "checksum" hash
of the image data.

This patch adds the ability to verify a signature of the image data
directly, using a verifier that is passed to the glance_store backend.
It is dependent on a glance_store patch which updates this verifier
object with the image data as it is creating the checksum (see
Depends-On below).

[1] http://bit.ly/1Q0M0C7
[2] https://review.openstack.org/#/c/188874/19

Depends-On: I43799e6a4a6643a23769af8d839a2beb4e0ff9bf
Partial-Bug: #1516031
Change-Id: If0c06b3094cecef6c8ca8a65753038b6b5a9d8fe
2016-02-18 14:20:16 -08:00
Jenkins 557564ca94 Merge "Port replicator to Python 3" 2015-10-05 14:12:28 +00:00
kairat_kushaev fd175a8dcc Fix mutable defaults in tests
Some test methods have mutables objects as default types. It
potentially can lead to unpredictable errors in tests and it is
considered as bad practice in python. So the patch replaces these
defaults with None and introduces default values in method body.

Change-Id: If523d8ddfb4c176ad2ba81c15858b78bbd89c80b
2015-09-28 14:36:27 +03:00
Jenkins 7499dc485b Merge "Use dictionary literal for dictionary creation" 2015-09-22 07:32:23 +00:00
Brianna Poulos 484ef1b40b Add image signing verification
This patch adds support for the image signing feature by adding the
ability for glance to verify a signature.

This patch still needs:
 * castellan added to global requirements (see Depends-On below)

Depends-On: I2283d2853d4ccd6d41d706db5b02cf6c74c5ba93
Change-Id: I0b0592a3526a4e4f5b39ae6ce8b4dedd0ccc31d9
Implements: blueprint image-signing-and-verification-support
2015-09-02 17:02:03 -04:00
Victor Stinner 25319368cc Port replicator to Python 3
* replication_dump(): explicit the JSON encoding (UTF-8) to not rely on
  the locale encoding, otherwise the function will fail on non-ASCII
  character if the locale encoding is ASCII (ex: POSIX locale aka "C")
* Use sorted() to get the sorted list of keys. dict.keys() returns a
  generator on Python 3 which has no sort() method.
* Fix FakeImageService: HTTP body is bytes
* utils.py: get the urllib module from six.moves
* tox.ini: add test_glance_replicator to Python 3.4

Change-Id: Iaded283c70f49abb2408565563c173f58fff2fc7
2015-08-16 11:50:08 +02:00
ankitagrawal 16ab5d7c17 Use dictionary literal for dictionary creation
Dictionary creation could be rewritten as a dictionary literal.
for example:

filters = {}
filter['namespace'] = namespace

could be rewritten as

filters = {'namespace': namespace}

Closes-Bug: 1482586
Change-Id: I860483e958296da248a579a6032c14370843d9e4
2015-08-07 06:00:35 -07:00
Kamil Rykowski 6c435ca491 Provide extra parameter for FakeDB
In our codebase for tests we are often using same pattern to initialize
FakeDB instance which by default resets the database state and puts
sample data into it. After that we manually reset it's state, which
makes no sense. Here are the steps we are performing right now:

1. Reset database state
2. Puts data into database
3. Reset database state

It would be cleaner (and slightly faster) if we can skip these redundant
steps (2,3) in case we need an empty database. Provided fix allows
developers who are writting tests to decide if sample data should be
initialized or not.

Change-Id: I9e03b1c26d9ad311b8ff4330d19b0db93e6d1157
2015-06-23 08:24:58 +02:00
Louis Taylor 0acff569e0 Move to graduated oslo.log module
This removes the log module from the oslo incubator directory.

Change-Id: Ib017cc2777e27c58b376c3138c9fba614783cc34
2015-03-12 11:48:24 +00:00
Louis Taylor d759a6fd1a Move from oslo.config to oslo_config
oslo_config was moved out of the oslo namespace in oslo.config>=1.6.0.

Related-to: blueprint drop-namespace-packages

Change-Id: I30ecbf8f9de77496fcb643c7ad9738d79ad359f0
2015-01-12 14:34:22 +00:00
Zhi Yan Liu 4afdb017aa To prevent client use v2 patch api to handle file and swift location
The change will be used to restrict client to download and delete any
file in glance-api server. The same resone and logic as what we did in
v1:
https://github.com/openstack/glance/blob/master/glance/api/v1/images.py#L429

Closes-Bug: bug/1400966
DocImpact

Note: Even this change could fully resolve the problem for Glance, but
we still need to fix this issue from glance_store perspective
separatelly due to other projects can use the lib directly.

Change-Id: I72dbead3cb2dcb87f52658ddb880e26880cc229b
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-12-15 14:25:48 +08:00
Zhi Yan Liu 348a5c31e5 Correct GlanceStoreException to provide valid message - Glance
This is the relevant change on glance side. The main change on
glance_store side is Ic4423405f831088fb51de7cfdf1243e9a0ff32ea ,
which be used to allow glance_store exception provide a proper error
message instead of None message all the time.

Note, once the change on glance_store side get merged, we need to land
this for glance before release new glance_store.

Change-Id: I0d6aa29bca3809da4c71d278ef17897eae15ee6c
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-11-26 21:05:09 +08:00
Julien Danjou fadbef8511 hacking: upgrade to 0.9.x serie
Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
2014-10-06 14:41:03 +02:00
Flavio Percoco e9e35c49a9 API support for random access to images
This patch adds support for random access to images to the API v2. It's
possible to partially access the image data by passing the offset where
the image should be fetched from and the size of the chunk expected.

Note that not all stores support random access to image data. In such
cases, the API will return an error mentioning the selected store
doesn't support such a feature.

DocImpact:
Content-Range header is now parsed to support random access to image
data.

Implements blueprint: restartable-image-download

Change-Id: Iade692a8197a9a1d9532711a5c572c505e5e7d20
2014-09-08 15:48:38 +02:00
Flavio Percoco f6e7992a68 Adopt glance.store library in Glance
This commits removes the old `store` package from glance and adopts the
usage of the new glance.store library. The library was designed to
preserve backwards compatibility as much as possible. In fact, most of
the changes in this patch are related to function args ordering and not
function renames or workflow changes.

Some changes that are worth mentioning:

1. Glance store doesn't rely on a global config object. All config
options must be explicitly registered.

2. All store operations now accepted an optional context. This is a
fallout from the context not being required in the `Store` constructor
anymore.

3. Store drivers are behind a private package called `_drivers` and
they're not suppose to be accessed directly. Instead, functions like
`get_store_from_scheme` should be used.

4. Stores are disabled by default

5. All the store specific options are under the `glance_store` group.

DocImpact:
The old store related configuration options have been moved under the
`glance_store` section. However, the old options will go through a
deprecation path. That is, they'll still be read from the `DEFAULT`
section to give deployers enough time to update their config files.

In k-2, the deprecated options will be completely obsolete.

Closes-bug: #1291848
Implements-blueprint: create-store-package

Change-Id: Iaacc70993ad5da292b93de42bbecda73d53b19fd
2014-09-08 15:48:36 +02:00
Louis Taylor 65c4e73104 Fix collection order issues and unit test failures
A randomized PYTHONHASHSEED caused the glance API to return certain data
in a nondeterministic order, breaking some tests. This patch sorts the
returned data before testing against a pre-sorted expected values.

This patch also fixes some unit test failures with the new version of
testtools (0.9.36) and directly calling setUp(). This was added to this
patch to avoid blocking more Glance tests.

Co-authored-by: Fei Long Wang <flwang@catalyst.net.nz>
Co-authored-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>

Partial-bug: #1348818

Change-Id: Ie92c6bb5663826713ca99e8f2f7d70f3faef6675
2014-08-23 21:34:26 +08:00
Tom Leaman 92ab00fca6 Enforce image_size_cap on v2 upload
image_size_cap should be checked and enforced on upload

Enforcement is in two places:
- on image metadata save
- during image save to backend store

Closes-Bug: 1315321
Change-Id: I45bfb360703617bc394e9e27fe17adf43b09c0e1
Co-Author: Manuel Desbonnet <manuel.desbonnet@hp.com>
2014-08-18 11:25:56 +01:00
Zhi Yan Liu 66d24bb1a1 Adding status field to image location -- domain and APIs changes
Adding a status field to image's each location property, each location
status can be 'active', 'pending_delete' and 'deleted'.

Under location's status information Scrubber service can make cleanup
based on DB records also but not a dedicated queue-file for each image.

This is second part of this change which covered DB API, domain and REST
API.

Partially-Implements BP: image-location-status

Change-Id: I744679e2dadbaec099aef33d8c5a3fe4ecf96865
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-07-11 14:15:33 +08:00
Brian Cline bebe906ee7 Uses None instead of mutables for function param defaults
Addressing bug 1307878, changes use of mutable lists and dicts as
default arguments and defaults them within the function. Otherwise,
those defaults can be unexpectedly persisted with the function between
invocations and erupt into mass hysteria on the streets.

To my knowledge there aren't known cases of the current use causing
specific issues, but needs addressing (even stylistically) to avoid
problems in the future -- ones that may crop up as extremely subtle or
intermittent bugs...or worse, security vulnerabilities.

In Glance's case there are ACL-related methods using this, so
although I haven't confirmed one way or the other yet, I've marked it
with SecurityImpact so that a more knowledgeable set of eyes can
review it in this context as well.

Closes-Bug: #1307878
SecurityImpact

Change-Id: Ic17c330eff701ff63701c0029b26db7093a1d73d
2014-04-15 02:29:23 -05:00
Flavio Percoco 1f6381a73f Don't enable all stores by default
Glance currently enables all stores by default. This patch changes that
by removing all stores that require manual configuration and leaving
those that work right out of the box.

Current behavior causes a lot of confusion to users since most of those
stores print errors when they're not configured correctly. All extra
stores should be enabled explicitly by users.

This fix makes tests use http locations. All other locations besides the
default ones should be tested in their own test suites.

DocImpact
Closes-bug: #1255556
Change-Id: I82073352641d3eb2ab3d6e9a6b64afc99a30dcc7
2014-03-10 10:40:31 +01:00
Fei Long Wang a8ef64c4ec Set image size to None after removing all locations
Based on current design, the image size should be updated to
None if there is no location assocaited with the image. This
patch fixes this issue and introduces some related changes.

Closes-Bug: #1263729

Change-Id: I893468f1dc320ea9434f07c3a32f978cd5941b33
2014-01-11 12:25:55 +08:00
ZhiQiang Fan 2bebf10901 Refactor tests.unit.utils:FakeDB.reset
glance.tests.unit.utils:FakeDB uses glance.db.simple.api which has
already implemented reset() functionality, the redundant code in
FakeDB should be removed.

Change-Id: I140e932e9cc531900cee503e20d3549549b13d27
Closes-Bug: #1264204
2013-12-26 12:24:10 +08:00
Venkatesh Sampath c3ebafa795 Introduce Task Info Table
- move 'input', 'message' and 'result' columns to table 'task_info'
- introduce migration script for the above db changes.
- appropriate tests are included

Co-authored-by: Nikhil Komawar <nikhil.komawar@rackspace.com>

partly implements bp async-glance-workers

Change-Id: I9867d609f4729572b72a44d1f05e353acf6c98d9
2013-12-05 16:30:38 +00:00
Flavio Percoco 90d6ef8130 Migrate to oslo.messaging
Glance currently uses a custom notifier and it has been maintaining it
for a long time. In a hope of reducing duplicated code and improving
cross-project contributions, this patch replaces the old notifier with
the one, recently developed, in oslo.messaging.

The oslo.messaging project is a port of the old oslo-rpc code to a
standalone, more stable and improved project. It brings all the benefits
that oslo-rpc would've brought as well as an easier way to integrate
with other projects.

This patch also:

    - Reduces the code shipped along with Glance since all the code
      copied from oslo-incubator related to the notifier is not needed
      anymore.
    - Improves the stability of existing, broker based, notifications.
    - Brings HA support.
    - Keeps backward compatibility by translating the old
      `notifier_strategy` into oslo.messaging drivers.

Changes to the code:

    - It is now necessary to pass the request context to the
      notification call.
    - Notifier package is no longer necessary. A notifier module was
      added instead.
    - New, notifier related, configurations were added.
    - A lot of code was removed

Since there's still not an official release, requirements.txt points to
the latest tarball created. A release for oslo.messaging is planned for
Icehouse.

docImpact
Implements bp oslo-messaging

Change-Id: I8cd84772bc5867e06b2a50ed7e15b9e86f0b94ad
2013-12-04 09:05:51 +01:00
Fei Long Wang d79861560b Adds domain level support for tasks
Includes:-
  - Domain Task class
  - Domain TaskFactory class
  - DB TaskRepo class
  - Necessary proxy classes for all of the above
  - Tasks related exceptions
  - Unit tests as applicable

Partially implement blueprint async-glance-workers

Change-Id: I619224bcc55b62303f3539454649528f2edc6e9d
2013-11-26 16:35:12 -05:00
iccha.sethi 262bdf68b4 Property Protection Layer
This patch introduces the property protection layer and the tests
associated with it

Related to bp api-v2-property-protection

Change-Id: Iaf2111bf07377ef6a4c89a621888077cc14be776
2013-09-04 17:47:48 +00:00
Zhi Yan Liu 85075f4b11 Scrubber refactoring
* Adding multiple locations image support.
* Adding lock protection to prevent race condition between glance-api
and glance-scrubber service.
* Refactoring scrub queue code.

Implement bp: glance-scrubber-refactoring
docImpact

Change-Id: I050ff212d73ace8e84dcd800245b608210d6b29a
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-09-04 12:36:25 +08:00
Zhi Yan Liu 4009cf90de Adding metadata checking to image location proxy layer
Enable image locaton proxy checking metadata when the location changing.
Implemented bp: location-proxy-metadata-checking

Change-Id: If411a454cd2c3e277ea9840cc3d83ec5125bb372
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-08-14 11:59:46 +08:00
amalaba 3cd819fa6e Simulate image_locations table in simple/api.py
Currently the simple/api.py does not implement any 'image_locations'
related actions as in sqlalchemy/api.py. Actions like image_create/
image-update etc in simple/api.py does not look at making appropriate
changes in the image_locations table as it does in sqlalchemy/api.py

Change-Id: Ifae710d3d820225218ba72d7a16652b03b64a24f
Fixes: Bug #1202985
2013-07-24 18:40:34 +05:30
Zhi Yan Liu 1e40cf967f Add/remove/replace locations from an image
This patch modifies the PATCH /v2/images/{id} API call. Clients can add,
remove and replace locations from the set of multiple locations
associated with a given image ID in the following way:

PATCH /images/1234
[{"op": "add", "path": "/locations/-",
  "value": {"url": "scheme3://path3", "metadata": {}}}]
PATCH /images/1234
[{"op": "add", "path": "/locations/1",
  "value": {"url": "scheme4://path4", "metadata": {}}}]
PATCH /images/1234
[{"op": "remove", "path": "/locations/2"}]
PATCH /images/1234
[{"op": "replace", "path": "/locations", "value": []}]
PATCH /images/5678
[{"op": "replace", "path": "/locations",
  "value": [{"url": "scheme5://path5", "metadata": {}},
            {"url": "scheme6://path6", "metadata": {}}]}]

Glance will check location correctness when client adding, and will
remove the image content from the store when client remove a location.

Implement bp: multiple-image-locations
docimpact

Change-Id: I845646fde22e18be27929b5ec70ef8041b6fa733
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2013-07-13 16:50:15 +08:00
John Bresnahan 74e4fe25dc Allow storage drivers to add metadata to locations
This patches allows a storage system to add metadata to a location.
For example, if a location is a file:// URL the storage system may
wish to add information about it like the following:
{'FS': Gluster, 'mountpoint': '/usr/local/', 'namespace': 'abc-efg-xyz'}
Such information can be useful to a client with access to the direct
URL (often times the URL alone cannot encode enough information).

With this change when new data is added to the store a dictionary
is returned along with URL.  That dictionary is then stored in the
DB with the URL.  It is up to each store to determine what is in this
metadata dictionary.  Possible way to do so are with a configuration
file.  This patch does not included storage systems (other than tests)
that set this information.

If the API service is configured with the follow options:

    show_multiple_locations = True

then the location and the location information is returned with the
image information in the field 'locations'.  locations is
a list with the following format:

{'url': '<url>', 'metadata': <a storage specific dict>}

With this patch it will always be a list of one, but future patches
relating to the blueprint multiple-image-locations will allow for more.

blueprint: direct-url-meta-data
blueprint: multiple-image-locations
docimpact: show_multiple_locations

Change-Id: Ia832b8a8366bb06bfbaa53871af39a6a10b5721d
2013-07-11 23:11:44 -10:00