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

Fix name error

parent c6619649
Changelog
=========
v0.13.0
------
* setting *PITHOS_SERVICE_TOKEN* is no longer required for feedback to work
* settings *PITHOS_PROXY_USER_SERVICES*, *PITHOS_USER_CATALOG_URL*, *PITHOS_USER_FEEDBACK_URL*,
*PITHOS_USER_LOGIN_URL* should be set
v0.10.0
------
* improve sql queries
......@@ -12,7 +18,7 @@ v0.10.0
v0.9.7
------
* Delegate feedback post request to Identity Provider (astakos)
New setting *PITHOS_SERVICE_TOKEN* is required to be set for feedback to
New setting *PITHOS_SERVICE_TOKEN* is required to be set for feedback to
work.
* Change API calls to include public objects in shared by me
......@@ -22,7 +28,7 @@ v0.9.6
v0.9.5
------
* Calculate the length of the last block properly.
* Calculate the length of the last block properly.
v0.9.4
------
......
......@@ -30,7 +30,7 @@ Configure in ``settings.py`` or a ``.conf`` file in ``/etc/synnefo`` if using sn
=============================== ==================================================== ============================================================
Name Default value Description
=============================== ==================================================== ============================================================
PROXY_USER_SERVICES True Whether to proxy user feedback and catalog services
PITHOS_PROXY_USER_SERVICES True Whether to proxy user feedback and catalog services
PITHOS_USER_CATALOG_URL \http://127.0.0.1:8000/im/service/api/v2.0/users/ Astakos User Catalog URL
PITHOS_USER_FEEDBACK_URL \http://127.0.0.1:8000/im/service/api/v2.0/feedback/ Astakos User Feedback URL
PITHOS_USER_LOGIN_URL \http://127.0.0.1:8000/login/ Astakos User Login URL
......@@ -48,7 +48,6 @@ PITHOS_BACKEND_QUOTA 50 GB (50 * 1024 ** 3)
PITHOS_BACKEND_VERSIONING auto Default versioning policy for containers
PITHOS_BACKEND_FREE_VERSIONING True Default versioning debit policy (default free)
PITHOS_UPDATE_MD5 True Update object checksums when using hashmaps
PITHOS_SERVICE_TOKEN '' Service token acquired by the identity provider (astakos)
=============================== ==================================================== ============================================================
To update checksums asynchronously, enable the queue, install snf-pithos-tools and use ``pithos-dispatcher``::
......
......@@ -42,6 +42,3 @@ PITHOS_BACKEND_BLOCK_PATH = '/usr/share/synnefo/pithos/data'
# Disable if checksums are not required or are computed asynchronously by an external process.
#PITHOS_UPDATE_MD5 = True
# Service Token acquired by identity provider.
#PITHOS_SERVICE_TOKEN = ''
......@@ -44,8 +44,7 @@ from django.utils.http import urlencode
from django.views.decorators.csrf import csrf_exempt
from pithos.api.settings import (
AUTHENTICATION_USERS, USER_LOGIN_URL, USER_FEEDBACK_URL, USER_CATALOG_URL,
SERVICE_TOKEN)
AUTHENTICATION_USERS, USER_LOGIN_URL, USER_FEEDBACK_URL, USER_CATALOG_URL)
from synnefo.lib.pool.http import get_http_connection
......
......@@ -58,8 +58,9 @@ from pithos.api.util import (
copy_or_move_object, get_int_parameter, get_content_length,
get_content_range, socket_read_iterator, SaveToBackendHandler,
object_data_response, put_object_block, hashmap_md5, simple_list_response,
api_method, retrieve_displayname, retrieve_uuid, retrieve_displaynames,
retrieve_uuids)
api_method,
# retrieve_uuid
)
from pithos.api.settings import UPDATE_MD5
......@@ -185,7 +186,6 @@ def account_list(request):
response.status_code = 204
return response
response.status_code = 200
put_account_translation_headers(response, accounts)
response.content = '\n'.join(accounts) + '\n'
return response
......@@ -201,7 +201,6 @@ def account_list(request):
except NotAllowedError:
raise Forbidden('Not allowed')
else:
meta['account_presentation'] = retrieve_username(x)
rename_meta_key(meta, 'modified', 'last_modified')
rename_meta_key(
meta, 'until_timestamp', 'x_account_until_timestamp')
......@@ -232,8 +231,6 @@ def account_meta(request, v_account):
external_quota=request.user_usage)
groups = request.backend.get_account_groups(
request.user_uniq, v_account)
for k in groups:
groups[k] = [retrieve_username(x) for x in groups[k]]
policy = request.backend.get_account_policy(
request.user_uniq, v_account, external_quota=request.user_usage)
except NotAllowedError:
......@@ -254,12 +251,12 @@ def account_update(request, v_account):
# badRequest (400)
meta, groups = get_account_headers(request)
for k in groups:
try:
groups[k] = [retrieve_uuid(x) for x in groups[k]]
except ItemNotExists, e:
raise BadRequest(
'Bad X-Account-Group header value: unknown account: %s' % e)
# for k in groups:
# try:
# groups[k] = [retrieve_uuid(request.token, x) for x in groups[k]]
# except ItemNotExists, e:
# raise BadRequest(
# 'Bad X-Account-Group header value: unknown account: %s' % e)
replace = True
if 'update' in request.GET:
replace = False
......@@ -636,9 +633,6 @@ def object_list(request, v_account, v_container):
object_meta = []
for meta in objects:
modified_by = meta.get('modified_by')
if modified_by:
meta['modified_by'] = retrieve_username(modified_by)
if len(meta) == 1:
# Virtual objects/directories.
object_meta.append(meta)
......
......@@ -62,9 +62,6 @@ QUOTAHOLDER_TOKEN = getattr(settings, 'PITHOS_QUOTAHOLDER_TOKEN', '')
# Update object checksums when using hashmaps.
UPDATE_MD5 = getattr(settings, 'PITHOS_UPDATE_MD5', True)
# Service Token acquired by identity provider.
SERVICE_TOKEN = getattr(settings, 'PITHOS_SERVICE_TOKEN', '')
RADOS_STORAGE = getattr(settings, 'PITHOS_RADOS_STORAGE', False)
RADOS_POOL_BLOCKS= getattr(settings, 'PITHOS_RADOS_POOL_BLOCKS', 'blocks')
RADOS_POOL_MAPS = getattr(settings, 'PITHOS_RADOS_POOL_MAPS', 'maps')
......@@ -65,7 +65,7 @@ from pithos.api.settings import (BACKEND_DB_MODULE, BACKEND_DB_CONNECTION,
BACKEND_QUOTA, BACKEND_VERSIONING,
BACKEND_FREE_VERSIONING,
AUTHENTICATION_URL, AUTHENTICATION_USERS,
SERVICE_TOKEN, COOKIE_NAME, USER_CATALOG_URL,
COOKIE_NAME, USER_CATALOG_URL,
RADOS_STORAGE, RADOS_POOL_BLOCKS,
RADOS_POOL_MAPS)
from pithos.backends import connect_backend
......@@ -164,13 +164,6 @@ def get_account_headers(request):
return meta, groups
def put_account_translation_headers(response, accounts):
for x in accounts:
k = smart_str('X-Account-Presentation-%s' % x, strings_only=True)
v = smart_str(retrieve_username(x), strings_only=True)
response[k] = v
def put_account_headers(response, meta, groups, policy):
if 'count' in meta:
response['X-Account-Container-Count'] = meta['count']
......@@ -241,9 +234,8 @@ def put_object_headers(response, meta, restricted=False):
if not restricted:
response['X-Object-Hash'] = meta['hash']
response['X-Object-UUID'] = meta['uuid']
modified_by = retrieve_displayname(meta['modified_by'])
response['X-Object-Modified-By'] = smart_str(
modified_by, strings_only=True)
meta['modified_by'], strings_only=True)
response['X-Object-Version'] = meta['version']
response['X-Object-Version-Timestamp'] = http_date(
int(meta['version_timestamp']))
......@@ -295,33 +287,37 @@ def is_uuid(str):
else:
return True
def retrieve_displayname(uuid):
##########################
# USER CATALOG utilities #
##########################
def retrieve_displayname(token, uuid):
try:
return get_displayname(
SERVICE_TOKEN, uuid, USER_CATALOG_URL, AUTHENTICATION_USERS)
token, uuid, USER_CATALOG_URL, AUTHENTICATION_USERS)
except:
# if it fails just leave the input intact
return uuid
def retrieve_displaynames(uuids):
def retrieve_displaynames(token, uuids):
return get_displaynames(
SERVICE_TOKEN, uuids, USER_CATALOG_URL, AUTHENTICATION_USERS)
token, uuids, USER_CATALOG_URL, AUTHENTICATION_USERS)
def retrieve_uuid(displayname):
def retrieve_uuid(token, displayname):
if is_uuid(displayname):
return displayname
uuid = get_user_uuid(
SERVICE_TOKEN, displayname, USER_CATALOG_URL, AUTHENTICATION_USERS)
token, displayname, USER_CATALOG_URL, AUTHENTICATION_USERS)
if not uuid:
raise ItemNotExists(displayname)
return uuid
def retrieve_uuids(displaynames):
def retrieve_uuids(token, displaynames):
return get_uuids(
SERVICE_TOKEN, displaynames, USER_CATALOG_URL, AUTHENTICATION_USERS)
token, displaynames, USER_CATALOG_URL, AUTHENTICATION_USERS)
def replace_permissions_displayname(holder):
def replace_permissions_displayname(token, holder):
try:
# check first for a group permission
account, group = holder.split(':')
......@@ -330,7 +326,7 @@ def replace_permissions_displayname(holder):
else:
return ':'.join([retrieve_uuid(account), group])
def replace_permissions_uuid(holder):
def replace_permissions_uuid(token, holder):
try:
# check first for a group permission
account, group = holder.split(':')
......@@ -346,9 +342,10 @@ def update_sharing_meta(request, permissions, v_account, v_container, v_object,
if len(perms) == 0:
return
perms['read'] = [replace_permissions_uuid(x) for x in perms.get('read', [])]
perms['write'] = \
[replace_permissions_uuid(x) for x in perms.get('write', [])]
# replace uuid with displayname
# perms['read'] = [replace_permissions_uuid(request.token, x) for x in perms.get('read', [])]
# perms['write'] = \
# [replace_permissions_uuid(request.token, x) for x in perms.get('write', [])]
ret = []
......@@ -601,14 +598,14 @@ def get_sharing(request):
'Bad X-Object-Sharing header value: missing prefix')
# replace displayname with uuid
try:
ret['read'] = \
[replace_permissions_displayname(x) for x in ret.get('read', [])]
ret['write'] = \
[replace_permissions_displayname(x) for x in ret.get('write', [])]
except ItemNotExists, e:
raise BadRequest(
'Bad X-Object-Sharing header value: unknown account: %s' % e)
# try:
# ret['read'] = \
# [replace_permissions_displayname(request.token, x) for x in ret.get('read', [])]
# ret['write'] = \
# [replace_permissions_displayname(request.token, x) for x in ret.get('write', [])]
# except ItemNotExists, e:
# raise BadRequest(
# 'Bad X-Object-Sharing header value: unknown account: %s' % e)
# Keep duplicates only in write list.
dups = [x for x in ret.get(
......@@ -1072,9 +1069,9 @@ def api_method(http_method=None, format_allowed=False, user_required=True,
if getattr(request, 'user', None) is None:
raise Unauthorized('Access denied')
assert getattr(request, 'user_uniq', None) != None
request.user_usage = get_pithos_usage(
request.user.get('usage', []))
request.user_usage = get_pithos_usage(request.user.get('usage', []))
request.token = request.GET.get('X-Auth-Token', request.META.get('HTTP_X_AUTH_TOKEN', token))
# The args variable may contain up to (account, container, object).
if len(args) > 1 and len(args[1]) > 256:
raise BadRequest('Container name too large.')
......
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