Commit a0b3d387 authored by Christos Stavrakakis's avatar Christos Stavrakakis

Revert "cyclades: Revert modular plankton backend functionality"

This reverts commit efea9ecb, because it
breaks existing unittests which mock
'synnefo.plankton.backend.PlanktonBackend'.
parent 9f25ede1
......@@ -59,8 +59,6 @@ urlpatterns = patterns(
)
PlanktonBackend = backend.get_backend()
def demux(request):
if request.method == 'GET':
return list_images(request)
......@@ -133,7 +131,7 @@ def list_images(request, detail=False):
log.debug('list_images detail=%s', detail)
since = utils.isoparse(request.GET.get('changes-since'))
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
images = b.list_images()
if since:
updated_since = lambda img: date_parse(img["updated_at"]) >= since
......@@ -182,7 +180,7 @@ def get_image_details(request, image_id):
# overLimit (413)
log.debug('get_image_details %s', image_id)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
reply = image_to_dict(image)
......@@ -204,7 +202,7 @@ def delete_image(request, image_id):
# overLimit (413)
log.info('delete_image %s', image_id)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
b.unregister(image_id)
log.info('User %s deleted image %s', request.user_uniq, image_id)
return HttpResponse(status=204)
......@@ -220,7 +218,7 @@ def list_metadata(request, image_id):
# overLimit (413)
log.debug('list_image_metadata %s', image_id)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
metadata = image['properties']
return util.render_metadata(request, metadata, use_values=False,
......@@ -240,7 +238,7 @@ def update_metadata(request, image_id):
req = utils.get_request_dict(request)
log.info('update_image_metadata %s %s', image_id, req)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
try:
metadata = req['metadata']
......@@ -267,7 +265,7 @@ def get_metadata_item(request, image_id, key):
# overLimit (413)
log.debug('get_image_metadata_item %s %s', image_id, key)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
val = image['properties'].get(key)
if val is None:
......@@ -298,7 +296,7 @@ def create_metadata_item(request, image_id, key):
raise faults.BadRequest('Malformed request.')
val = metadict[key]
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
properties = image['properties']
properties[key] = val
......@@ -321,7 +319,7 @@ def delete_metadata_item(request, image_id, key):
# overLimit (413),
log.info('delete_image_metadata_item %s %s', image_id, key)
with PlanktonBackend(request.user_uniq) as b:
with backend.PlanktonBackend(request.user_uniq) as b:
image = b.get_image(image_id)
properties = image['properties']
properties.pop(key, None)
......
......@@ -51,13 +51,12 @@ from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata,
Network, NetworkInterface, SecurityGroup,
BridgePoolTable, MacPrefixPoolTable, IPAddress,
IPPoolTable)
from synnefo.plankton.backend import get_backend
from synnefo.plankton.backend import PlanktonBackend
from synnefo.cyclades_settings import cyclades_services, BASE_HOST
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
PlanktonBackend = get_backend()
COMPUTE_URL = \
join_urls(BASE_HOST,
get_service_path(cyclades_services, "compute", version="v2.0"))
......
......@@ -548,7 +548,7 @@ def image_to_dict(location, metadata, permissions):
return image
class JSONFileBackend(PlanktonBackend):
class JSONFileBackend(object):
"""
A dummy image backend that loads available images from a file with json
formatted content.
......@@ -590,7 +590,6 @@ class JSONFileBackend(PlanktonBackend):
def get_backend():
backend_module = getattr(settings, 'PLANKTON_BACKEND_MODULE', None)
if not backend_module:
# no setting set
return PlanktonBackend
......
......@@ -43,12 +43,10 @@ from django.http import HttpResponse
from snf_django.lib import api
from snf_django.lib.api import faults
from synnefo.util.text import uenc
from synnefo.plankton.backend import get_backend
from synnefo.plankton.backend import PlanktonBackend
from synnefo.plankton.backend import split_url
PlanktonBackend = get_backend()
FILTERS = ('name', 'container_format', 'disk_format', 'status', 'size_min',
'size_max')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment