Commit 06374392 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Merge branch 'master' of https://code.grnet.gr/git/pithos

parents b7108deb 976103c5
#
# Copyright (c) 2011 Greek Research and Technology Network
#
from api.models import Container, Object, Metadata
from django.contrib import admin
admin.site.register(Container)
admin.site.register(Object)
admin.site.register(Metadata)
\ No newline at end of file
......@@ -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')
......
#
# Copyright (c) 2011 Greek Research and Technology Network
#
from django.db import models
class Container(models.Model):
account = models.CharField(max_length = 256)
name = models.CharField(max_length = 256)
date_created = models.DateTimeField(auto_now_add = True)
def __unicode__(self):
return self.name
class Object(models.Model):
container = models.ForeignKey(Container)
name = models.CharField(max_length = 1024)
length = models.IntegerField()
type = models.CharField(max_length = 256)
hash = models.CharField(max_length = 256)
data = models.FileField(upload_to = 'data', max_length = 256)
date_created = models.DateTimeField(auto_now_add = True)
date_modified = models.DateTimeField(auto_now = True)
def __unicode__(self):
return self.name
class Metadata(models.Model):
object = models.ForeignKey(Object)
name = models.CharField(max_length = 256)
value = models.CharField(max_length = 1024)
date_created = models.DateTimeField(auto_now_add = True)
date_modified = models.DateTimeField(auto_now = True)
\ No newline at end of file
from django.db import models
# Create your models here.
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):
......
......@@ -100,7 +100,7 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.admindocs',
# 'django.contrib.admin',
# 'django.contrib.admindocs',
'api'
)
......@@ -3,12 +3,8 @@
#
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^v1/', include('pithos.api.urls')),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls))
(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