Revision 028f4731 snf-cyclades-app/synnefo/plankton/backend.py
b/snf-cyclades-app/synnefo/plankton/backend.py | ||
---|---|---|
44 | 44 |
- location: generated based on the file's path |
45 | 45 |
- name: stored as a user meta |
46 | 46 |
- owner: the file's account |
47 |
- properties: stored as user meta prefixed with PROPERTY_PREFIX
|
|
47 |
- property_*: stored as user meta prefixed with PROPERTY_PREFIX
|
|
48 | 48 |
- size: the 'bytes' meta |
49 | 49 |
- status: stored as a system meta |
50 | 50 |
- store: is always 'pithos' |
... | ... | |
69 | 69 |
|
70 | 70 |
PLANKTON_DOMAIN = 'plankton' |
71 | 71 |
PLANKTON_PREFIX = 'plankton:' |
72 |
PROPERTY_PREFIX = 'property:'
|
|
72 |
PROPERTY_PREFIX = 'property_'
|
|
73 | 73 |
|
74 |
PLANKTON_META = ('container_format', 'disk_format', 'name', 'properties',
|
|
74 |
PLANKTON_META = ('container_format', 'disk_format', 'name', |
|
75 | 75 |
'status', 'created_at') |
76 | 76 |
|
77 | 77 |
from pithos.backends.util import PithosBackendPool |
... | ... | |
202 | 202 |
|
203 | 203 |
prefixed = {} |
204 | 204 |
for key, val in meta.items(): |
205 |
if key in PLANKTON_META: |
|
206 |
if key == "properties": |
|
207 |
val = json.dumps(val) |
|
205 |
if key in PLANKTON_META or key.startswith(PROPERTY_PREFIX): |
|
208 | 206 |
prefixed[PLANKTON_PREFIX + key] = val |
209 | 207 |
|
210 | 208 |
self.backend.update_object_meta(self.user, account, container, name, |
... | ... | |
340 | 338 |
permissions["read"] = list(read) |
341 | 339 |
self._update_permissions(image_url, permissions) |
342 | 340 |
meta = {} |
343 |
meta["properties"] = metadata.pop("properties", {}) |
|
344 | 341 |
meta.update(**metadata) |
345 | 342 |
|
346 | 343 |
self._update_meta(image_url, meta) |
... | ... | |
390 | 387 |
|
391 | 388 |
# Update rest metadata |
392 | 389 |
meta = {} |
393 |
meta['properties'] = metadata.pop('properties', {}) |
|
394 | 390 |
# Add creation(register) timestamp as a metadata, to avoid extra |
395 | 391 |
# queries when retrieving the list of images. |
396 | 392 |
meta['created_at'] = time() |
... | ... | |
494 | 490 |
# Remove plankton prefix |
495 | 491 |
key = key.replace(PLANKTON_PREFIX, "") |
496 | 492 |
# Keep only those in plankton meta |
497 |
if key in PLANKTON_META: |
|
498 |
if key == "properties": |
|
499 |
image[key] = json.loads(val) |
|
500 |
elif key == "created_at": |
|
493 |
if key in PLANKTON_META or key.startswith(PROPERTY_PREFIX): |
|
494 |
if key == "created_at": |
|
501 | 495 |
# created timestamp is return in 'created_at' field |
502 | 496 |
pass |
503 | 497 |
else: |
Also available in: Unified diff