commit b2f94a0ca54932e0968e684c35cb90f617c6c002
Author: Christos Stavrakakis <cstavr@grnet.gr>
Date:   Mon Nov 26 14:20:40 2012 +0200

    Make Plankton API return all available images
    
    Modify Plankton API, such that GET to /images/ retrieves a list of
    available images that the authenticated user has access to. This
    includes images owned by the user, images shared with the user and
    public images.

diff --git a/snf-cyclades-app/synnefo/plankton/urls.py b/snf-cyclades-app/synnefo/plankton/urls.py
index 2dfca48..3e0e56b 100644
--- a/snf-cyclades-app/synnefo/plankton/urls.py
+++ b/snf-cyclades-app/synnefo/plankton/urls.py
@@ -39,7 +39,7 @@ from synnefo.plankton import views
 
 def demux(request):
     if request.method == 'GET':
-        return views.list_public_images(request)
+        return views.list_images(request)
     elif request.method == 'POST':
         return views.add_image(request)
     else:
@@ -77,11 +77,9 @@ def demux_members(request, image_id, member):
 
 urlpatterns = patterns('',
     (r'^images/$', demux),
-    (r'^images/detail$', views.list_public_images, {'detail': True}),
+    (r'^images/detail$', views.list_images, {'detail': True}),
     (r'^images/([\w-]+)$', demux_image),
     (r'^images/([\w-]+)/members$', demux_image_members),
     (r'^images/([\w-]+)/members/([\w@._-]+)$', demux_members),
-    (r'^shared-images/$', views.list_shared_images),
-    (r'^shared-images/detail', views.list_shared_images, {'detail': True}),
-    (r'^shared-images/([\w@._-]+)$', views.list_shared_images_with)
+    (r'^shared-images/([\w@._-]+)$', views.list_shared_images)
 )
diff --git a/snf-cyclades-app/synnefo/plankton/views.py b/snf-cyclades-app/synnefo/plankton/views.py
index 4aa605a..1ce4fb3 100644
--- a/snf-cyclades-app/synnefo/plankton/views.py
+++ b/snf-cyclades-app/synnefo/plankton/views.py
@@ -226,16 +226,12 @@ def list_image_members(request, image_id):
 
 
 @plankton_method('GET')
-def list_public_images(request, detail=False):
-    """Return a list of public VM images.
+def list_images(request, detail=False):
+    """Return a list of available images.
 
-    Described in:
-    3.1. Requesting a List of Public VM Images
-    3.2. Requesting Detailed Metadata on Public VM Images
-    3.3. Filtering Images Returned via GET /images andGET /images/detail
+    This includes images owned by the user, images shared with the user and
+    public images.
 
-    Extensions:
-      * Image ID is returned in both compact and detail listings
     """
 
     def get_request_params(keys):
@@ -257,7 +253,7 @@ def list_public_images(request, detail=False):
     assert params['sort_key'] in SORT_KEY_OPTIONS
     assert params['sort_dir'] in SORT_DIR_OPTIONS
 
-    images = request.backend.list_public(filters, params)
+    images = request.backend.list(filters, params)
 
     # Remove keys that should not be returned
     fields = DETAIL_FIELDS if detail else LIST_FIELDS
@@ -271,7 +267,7 @@ def list_public_images(request, detail=False):
 
 
 @plankton_method('GET')
-def list_shared_images_with(request, member):
+def list_shared_images(request, member):
     """Request shared images
 
     Described in:
@@ -282,10 +278,10 @@ def list_shared_images_with(request, member):
         the users's images that are accessible by `member`.
     """
 
-    log.debug('list_shared_images_with %s', member)
+    log.debug('list_shared_images %s', member)
 
     images = []
-    for image in request.backend.iter_shared(member):
+    for image in request.backend.iter_shared(member=member):
         image_id = image['id']
         images.append({'image_id': image_id, 'can_share': False})
 
@@ -350,38 +346,3 @@ def update_image_members(request, image_id):
 
     request.backend.replace_users(image_id, members)
     return HttpResponse(status=204)
-
-
-@plankton_method('GET')
-def list_shared_images(request, detail=False):
-    def get_request_params(keys):
-        params = {}
-        for key in keys:
-            val = request.GET.get(key, None)
-            if val is not None:
-                params[key] = val
-        return params
-
-    log.debug('list_shared_images detail=%s, request %s', detail, request)
-
-    filters = get_request_params(FILTERS)
-    params = get_request_params(PARAMS)
-
-    params.setdefault('sort_key', 'created_at')
-    params.setdefault('sort_dir', 'desc')
-
-    assert params['sort_key'] in SORT_KEY_OPTIONS
-    assert params['sort_dir'] in SORT_DIR_OPTIONS
-
-    images = request.backend.list(filters, params)
-    images = filter(lambda x: not x['is_public'], images)
-
-    # Remove keys that should not be returned
-    fields = DETAIL_FIELDS if detail else LIST_FIELDS
-    for image in images:
-        for key in image.keys():
-            if key not in fields:
-                del image[key]
-
-    data = json.dumps(images, indent=settings.DEBUG)
-    return HttpResponse(data)
