Commit 976103c5 authored by Antony Chazapis's avatar Antony Chazapis
Browse files

Testing containers with the cloudfiles python bindings.

parent e64922a2
......@@ -37,7 +37,7 @@ def authenticate(request):
response = HttpResponse(status = 204)
response['X-Auth-Token'] = 'eaaafd18-0fed-4b3a-81b4-663c99ec1cbb'
# TODO: Do we support redirections?
#response['X-Storage-Url'] = 'https://storage.grnet.gr/pithos/v1.0/<some reference>'
response['X-Storage-Url'] = 'http://127.0.0.1:8000/v1/asdf'
return response
def account_demux(request, v_account):
......@@ -84,11 +84,11 @@ def account_meta(request, v_account):
# unauthorized (401),
# badRequest (400)
container_count, bytes_count = get_account_meta(request.user)
info = get_account_meta(request.user)
response = HttpResponse(status = 204)
response['X-Account-Container-Count'] = container_count
response['X-Account-Total-Bytes-Used'] = bytes_count
response['X-Account-Container-Count'] = info['count']
response['X-Account-Bytes-Used'] = info['bytes']
return response
@api_method('GET', format_allowed = True)
......@@ -127,11 +127,11 @@ def container_meta(request, v_account, v_container):
# unauthorized (401),
# badRequest (400)
object_count, bytes_count = get_container_meta(request.user, v_container)
info = get_container_meta(request.user, v_container)
response = HttpResponse(status = 204)
response['X-Container-Object-Count'] = object_count
response['X-Container-Bytes-Used'] = bytes_count
response['X-Container-Object-Count'] = info['count']
response['X-Container-Bytes-Used'] = info['bytes']
return response
@api_method('PUT')
......
import cloudfiles
conn = cloudfiles.get_connection('jsmith', '1234567890', authurl = 'http://127.0.0.1:8000/v1')
print 'Authenticated. Token: %s' % conn.token
print 'Container count: %d Total bytes: %d' % conn.get_info()
containers = conn.get_all_containers()
print 'Found: %d containers' % len(containers)
for container in containers:
print container.name
containers = conn.list_containers_info()
for container in containers:
print container
container = 'asdf'
conn.create_container(container)
cont = conn.get_container(container)
print 'Got container %s.' % container
print 'Object count: %s Total bytes: %s' % (cont.object_count, cont.size_used)
conn.delete_container(container)
......@@ -28,7 +28,7 @@ def binary_search_name(a, x, lo = 0, hi = None):
raise ValueError()
def get_account_meta(account):
logging.debug("get_account_meta: %s %s", account, name)
logging.debug("get_account_meta: %s", account)
return {'count': 13, 'bytes': 3148237468}
def create_container(account, name):
......
......@@ -5,5 +5,6 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^v1$', include('pithos.api.urls')),
(r'^v1/', include('pithos.api.urls'))
)
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