56 |
56 |
from operator import itemgetter
|
57 |
57 |
from time import gmtime, strftime
|
58 |
58 |
from functools import wraps, partial
|
|
59 |
from synnefo.api import faults
|
59 |
60 |
|
60 |
61 |
from django.conf import settings
|
61 |
62 |
|
... | ... | |
284 |
285 |
@handle_backend_exceptions
|
285 |
286 |
def add_user(self, image_id, user):
|
286 |
287 |
image = self.get_image(image_id)
|
287 |
|
assert image, "Image not found"
|
|
288 |
if not image:
|
|
289 |
raise faults.ItemNotFound
|
288 |
290 |
|
289 |
291 |
location = image['location']
|
290 |
292 |
permissions = self._get_permissions(location)
|
... | ... | |
394 |
396 |
|
395 |
397 |
def list_users(self, image_id):
|
396 |
398 |
image = self.get_image(image_id)
|
397 |
|
assert image, "Image not found"
|
|
399 |
if not image:
|
|
400 |
raise faults.ItemNotFound
|
398 |
401 |
|
399 |
402 |
permissions = self._get_permissions(image['location'])
|
400 |
403 |
return [user for user in permissions.get('read', []) if user != '*']
|
... | ... | |
471 |
474 |
@handle_backend_exceptions
|
472 |
475 |
def remove_user(self, image_id, user):
|
473 |
476 |
image = self.get_image(image_id)
|
474 |
|
assert image, "Image not found"
|
|
477 |
if not image:
|
|
478 |
raise faults.ItemNotFound
|
475 |
479 |
|
476 |
480 |
location = image['location']
|
477 |
481 |
permissions = self._get_permissions(location)
|
... | ... | |
484 |
488 |
@handle_backend_exceptions
|
485 |
489 |
def replace_users(self, image_id, users):
|
486 |
490 |
image = self.get_image(image_id)
|
487 |
|
assert image, "Image not found"
|
|
491 |
if not image:
|
|
492 |
raise faults.ItemNotFound
|
488 |
493 |
|
489 |
494 |
location = image['location']
|
490 |
495 |
permissions = self._get_permissions(location)
|
... | ... | |
497 |
502 |
def update(self, image_id, params):
|
498 |
503 |
image = self.get_image(image_id)
|
499 |
504 |
assert image, "Image not found"
|
|
505 |
if not image:
|
|
506 |
raise faults.ItemNotFound
|
500 |
507 |
|
501 |
508 |
location = image['location']
|
502 |
509 |
is_public = params.pop('is_public', None)
|
... | ... | |
521 |
528 |
def unregister(self, image_id):
|
522 |
529 |
"""Unregister an image."""
|
523 |
530 |
image = self.get_image(image_id)
|
524 |
|
assert image, "Image not found"
|
|
531 |
if not image:
|
|
532 |
raise faults.ItemNotFound
|
525 |
533 |
|
526 |
534 |
location = image["location"]
|
527 |
535 |
# Unregister the image by removing all metadata from domain
|