Commit Graph

22 Commits

Author SHA1 Message Date
Erno Kuvaja
7c55ce4a5a Unify using six.moves.range rename everywhere
Mainly to improve consistency, use range() from six.moves
renames across glance.

Behaves consistently like py2 xrange() and py3 range().

Change-Id: I542fcb2a762cf4b34c30fc796854c6fcf305d798
2015-02-25 12:13:59 +00:00
Zhi Yan Liu
138875b7c3 Add capabilities to storage driver
Storage capabilities is used to indicate the static and dynamic ability
of the storage driver object based on current driver implementation or
particular driver configuration and backend status.

Use storage capabilities glance_store can do more proper operations on
backend to support upper layer request, like to enable or disable add()
function to glance, or if allow glance reuse driver instance for all
request according to whether the driver and/or backend is stateless.

This patch implemented some initial capabilities for existing drivers,
and change the foundational code to make them be aware. Mainly it
contains:

1. Implemented essential code to enable driver capabilities, adding
necessary capabilities.

2. Added a generic checker on necessary storage operations, to make sure
the capabilities of the driver are capable of handling requested
operation. We can enhance the check logic as needed easily in future.

3. Added a callback based schedule logic to update dynamic capabilities
of store when operator enabled it by a option.

4. Refactoring on existing disablement logic on driver add() interface,
to use consistent capabilities way to handle it, removed add_disabled().

5. Therefor the related exception conversion logic for other interfaces
are redundant, due to now we can raise proper exception directly from
the checker.

6. Added the logic to recreate drive object if the storage and/or driver
isn't stateless.

Few minor changes need to be added to Glance side:
Change Ibbc85b6bc2ea98c564d316db2874d7df5aac32a6 .

docImpact
Implements: blueprint store-capabilities

Change-Id: Iedf0d4f829e46ca64c3f4fc6a7dfee54d9b0605b
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2015-02-08 12:41:47 +08:00
Abhijeet Malawade
6b9cfa2951 Validate metadata JSON file
If metadata is not valid dictionary then glance-api
throws 'internal server' error.

Validating metadata JSON file using jsonschema library
at configuration stage and caching metadata and using it
directly when new image being added.
Metadata JSON file requires 'id' and 'mountpoint' keys
to be 'string'. If value of 'id' and 'mountpoint' are not
string then it will raise ValidationError error.
After getting exception during json data validation,
'BadStoreConfiguration' exception will be raised.

If metadata file is list of dicts containing multiple mountpoints
then returned image metadata as dict containing exact mountpoint
where image is stored.

If image path do not starts with any of the 'mountpoint' provided
in metadata JSON file then error is logged and empty
dictionary is returned to glance api.

DocImpact:
Metadata JSON schema file should be valid object. This JSON object
should contain keys 'id', 'mountpoint' and value of both keys
should be string.

Example of valid metadata JSON:

1. If there is only one mountpoint-
{
  "id": "f0781415-cf81-47cd-8860-b83f9c2a415c",
  "mountpoint": "/var/lib/glance/images/"
}

2. If there are more than one mountpoints-
[
  {
    "id": "f0781415-cf81-47cd-8860-b83f9c2a415c",
    "mountpoint": "/var/lib/glance/images1/"
  },
  {
    "id": "asd81415-cf81-47cd-8860-b83f9c2a415c",
    "mountpoint": "/var/lib/glance/images2/"
  }
]

Change-Id: I76b0a0de54e909fb0ec90bd7f9972da76a2501eb
Closes-Bug: 1401778
2015-01-29 05:50:01 -08:00
Louis Taylor
94554c606f Move from oslo.utils to oslo_utils
oslo_utils has been moved out of the oslo namespace.

bp drop-namespace-packages

Change-Id: Id4ccf076983592026d35407107e79cf1575248ce
2015-01-09 20:16:20 +00:00
Zhi Yan Liu
0584204175 Switch to using oslo.utils
This change switched glance_store to using oslo.utils. It is not good to
add dependency on oslo-incubator if we can avoid it.

Change-Id: I9efe3d57e0ce64296c7a75838bd2ee19249f0fa8
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-09-29 13:11:48 +08:00
Zhi Yan Liu
22dbccb491 Enhance configuration handling
1. Changed drivers to prevent using global CONF but access it from
client by interface.
2. Corrected swift driver to involve options from swift driver utils,
allow glance_store exports and registers them for client.
3. Added missing test cases for the functions of swift driver util.

Change-Id: I8fac6800efde202e29179791ea05c4814ec58435
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-09-24 11:56:11 +08:00
Oleksii Chuprykov
71ae81d69c Fix H402
Fix `one line docstring needs punctuation.`
Remove H402 from ignore list.

Change-Id: I0cd3b88467067cdb10d41f86cc94e075da141ac0
2014-09-20 21:13:41 +03:00
Jenkins
f607390a3e Merge "Return the right filesize when chunk_size != None" 2014-09-09 00:40:53 +00:00
Flavio Percoco
699020e0e9 Return the right filesize when chunk_size != None
The filesystem store kept returning the full file size even when
chunk_size was not None. This patch fixes that issue.

Change-Id: Ifa7d08cabe4485e1f9f4bf2d21ce7e307236104b
2014-09-08 15:44:29 +02:00
Zhi Yan Liu
706f911271 Allowing operator to configure a permission for image file in fs store
In this way the user other service used, e.g. Nova, who consumes the
image could be the exclusive member of the group that owns the files
created.

Closes-bug: 1264302
Related-Id: I4d543d205b0805fe00dcab1b0872c0a5e0f97a5f
Change-Id: Iec8396f92ed11531dccb82957da2455ca333430a
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-09-08 11:30:17 +08:00
Flavio Percoco
ebd66cf189 Complete random_access for the filesystem store
This patch completes the support for random_access for the filesystem
store. It adds the required tests and modifies `ChunkFile` in a way that
it keeps backwards compatibility and adds support for this feature.

Change-Id: Ifaf6488165616c87debbb86b9dffa780df8c4b5f
Implements-blueprint: restartable-image-download
2014-09-05 10:09:33 +02:00
Flavio Percoco
a1c59a1575 Rename glance.store to glance_store
Given the existing, known issues, with python namespaces, pip and
setuptools, we've decided to rename glance.store into glance_store.

Change-Id: I3f02ce78b3d64f34744e5116652bfbb4f3062cbf
2014-08-28 10:09:36 +02:00
Jenkins
e47b51e0dc Merge "Port swift store" 2014-07-31 12:40:00 +00:00
Flavio Percoco
7b858be0f9 Split CHUNKSIZE into WRITE/READ_CHUNKSIZE
See I4e0c563b8f3a5ced8f65fcca83d341a97729a5d4 for a detailed
explanation.

Change-Id: I7d366f324b2699be0be610c1dde1db7fc4045dfd
2014-07-30 15:37:44 +00:00
Flavio Percoco
219eaa22c2 Port swift store
Change-Id: Ie070eb95b22729e30e7ced359e890e69e590d04c
2014-07-29 16:43:03 +02:00
Flavio Percoco
80af4f414a Fix flake8 errors 2014-07-09 15:58:38 +02:00
Flavio Percoco
3b3288954e Pull multipath support from glance/master 2014-07-04 16:05:33 +02:00
Flavio Percoco
7fffabed70 Move exceptions out of common and add backends.py 2014-06-12 11:42:45 +02:00
Flavio Percoco
e3278ac0a7 Move options registration to __init__ 2014-04-07 15:40:31 +02:00
Flavio Percoco
8cdda79731 Filesystem driver restored
* Don't pass context and location to the Store init
* Use 1 config object and pass that to the store
* Pass context to each method call
* Don't use mox, use mock instead
2014-02-10 14:51:47 +01:00
Flavio Percoco
d6c5389bde Config & Import fixes 2014-01-30 17:59:48 +01:00
Flavio Percoco
28d0258873 Add tests w/ some fixes, although they don't run yet 2014-01-30 11:21:22 +01:00