Revision 6ef51e9f snf-app/synnefo/plankton/backend.py
b/snf-app/synnefo/plankton/backend.py | ||
---|---|---|
223 | 223 |
def close(self): |
224 | 224 |
self.backend.close() |
225 | 225 |
|
226 |
def delete(self, image_id): |
|
227 |
image = self.get_image(image_id) |
|
228 |
account, container, object = split_location(image['location']) |
|
229 |
self.backend.delete_object(self.user, account, container, object) |
|
230 |
|
|
226 | 231 |
def get_data(self, location): |
227 | 232 |
account, container, object = split_location(location) |
228 | 233 |
size, hashmap = self.backend.get_object_hashmap(self.user, account, |
... | ... | |
241 | 246 |
location = get_location(account, container, object) |
242 | 247 |
return self._get_image(location) |
243 | 248 |
|
249 |
def iter(self): |
|
250 |
"""Iter over all images available to the user""" |
|
251 |
|
|
252 |
backend = self.backend |
|
253 |
for account in backend.list_accounts(self.user): |
|
254 |
for container in backend.list_containers(self.user, account, |
|
255 |
shared=True): |
|
256 |
for path, version_id in backend.list_objects(self.user, |
|
257 |
account, container, domain=PLANKTON_DOMAIN): |
|
258 |
location = get_location(account, container, path) |
|
259 |
image = self._get_image(location) |
|
260 |
if image: |
|
261 |
yield image |
|
262 |
|
|
244 | 263 |
def iter_public(self, filters): |
245 | 264 |
backend = self.backend |
246 | 265 |
|
... | ... | |
284 | 303 |
except (NameError, NotAllowedError): |
285 | 304 |
continue |
286 | 305 |
|
306 |
def list(self): |
|
307 |
"""Iter over all images available to the user""" |
|
308 |
|
|
309 |
return list(self.iter()) |
|
310 |
|
|
287 | 311 |
def list_public(self, filters, params): |
288 | 312 |
images = list(self.iter_public(filters)) |
289 | 313 |
key = itemgetter(params.get('sort_key', 'created_at')) |
Also available in: Unified diff