Commit 3e963f99 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Merge branch 'feature-snf-django' into develop

Conflicts:
	docs/older/Changelog.pithos-app
	snf-astakos-app/astakos/im/api/__init__.py
	snf-pithos-app/pithos/api/util.py
parents 79766cfc f1122a60
......@@ -34,4 +34,5 @@ snf-quotaholder-app/quotaholder_django/version.py
*.iml
*.graffle
snf-stats-app/synnefo_stats/version.py
snf-astakos-client/astakosclient/version.py
astakosclient/astakosclient/version.py
snf-django-lib/snf_django/version.py
......@@ -16,6 +16,8 @@ Released: UNRELEASED
Synnefo-wide
------------
* Create 'snf_django' Python package to hold common code for all Synnefo
components.
Astakos
-------
......@@ -25,6 +27,8 @@ Cyclades
Pithos
------
* Remove PITHOS_AUTHENTICATION_USERS setting, which was used to override
astakos users.
Tools
-----
......
......@@ -145,7 +145,7 @@ class AstakosClient():
# Get the connection object
with self.conn_class(self.netloc) as conn:
# Send request
(data, status) = \
(message, data, status) = \
_do_request(conn, method, request_path, **kwargs)
except Exception as err:
self.logger.error("Failed to send request: %s" % repr(err))
......@@ -154,15 +154,15 @@ class AstakosClient():
# Return
self.logger.debug("Request returned with status %s" % status)
if status == 400:
raise BadRequest(data)
raise BadRequest(message, data)
elif status == 401:
raise Unauthorized(data)
raise Unauthorized(message, data)
elif status == 403:
raise Forbidden(data)
raise Forbidden(message, data)
elif status == 404:
raise NotFound(data)
raise NotFound(message, data)
elif status < 200 or status >= 300:
raise AstakosClientException(data, status)
raise AstakosClientException(message, data, status)
return simplejson.loads(unicode(data))
# ------------------------
......@@ -314,4 +314,5 @@ def _do_request(conn, method, url, **kwargs):
length = response.getheader('content-length', None)
data = response.read(length)
status = int(response.status)
return (data, status)
message = response.reason
return (message, data, status)
......@@ -33,36 +33,29 @@
class AstakosClientException(Exception):
def __init__(self, message, status=0):
def __init__(self, message='', details='', status=None):
self.message = message
self.status = status
def __str__(self):
return repr(self.message)
self.details = details
if not hasattr(self, 'status'):
self.status = status
super(AstakosClientException,
self).__init__(self.message, self.details, self.status)
class BadRequest(AstakosClientException):
def __init__(self, message):
"""400 Bad Request"""
super(BadRequest, self).__init__(message, 400)
status = 400
class Unauthorized(AstakosClientException):
def __init__(self, message):
"""401 Invalid X-Auth-Token"""
super(Unauthorized, self).__init__(message, 401)
status = 401
class Forbidden(AstakosClientException):
def __init__(self, message):
"""403 Forbidden"""
super(Forbidden, self).__init__(message, 403)
status = 403
class NotFound(AstakosClientException):
def __init__(self, message):
"""404 Not Found"""
super(NotFound, self).__init__(message, 404)
status = 404
class NoUserName(AstakosClientException):
......
......@@ -71,35 +71,39 @@ def _request_offline(conn, method, url, **kwargs):
def _request_status_302(conn, method, url, **kwargs):
"""This request returns 302"""
message = "FOUND"
status = 302
data = '<html>\r\n<head><title>302 Found</title></head>\r\n' \
'<body bgcolor="white">\r\n<center><h1>302 Found</h1></center>\r\n' \
'<hr><center>nginx/0.7.67</center>\r\n</body>\r\n</html>\r\n'
return (data, status)
return (message, data, status)
def _request_status_404(conn, method, url, **kwargs):
"""This request returns 404"""
message = "Not Found"
status = 404
data = '<html><head><title>404 Not Found</title></head>' \
'<body><h1>Not Found</h1><p>The requested URL /foo was ' \
'not found on this server.</p><hr><address>Apache Server ' \
'at example.com Port 80</address></body></html>'
return (data, status)
return (message, data, status)
def _request_status_401(conn, method, url, **kwargs):
"""This request returns 401"""
message = "UNAUTHORIZED"
status = 401
data = "Invalid X-Auth-Token\n"
return (data, status)
return (message, data, status)
def _request_status_400(conn, method, url, **kwargs):
"""This request returns 400"""
message = "BAD REQUEST"
status = 400
data = "Method not allowed.\n"
return (data, status)
return (message, data, status)
def _request_ok(conn, method, url, **kwargs):
......@@ -136,7 +140,7 @@ def _req_authenticate(conn, method, url, **kwargs):
if "usage=1" not in url:
# Strip `usage' key from `user'
del user['usage']
return (simplejson.dumps(user), 200)
return ("", simplejson.dumps(user), 200)
def _req_catalogs(conn, method, url, **kwargs):
......@@ -176,7 +180,7 @@ def _req_catalogs(conn, method, url, **kwargs):
return_catalog = {"displayname_catalog": catalogs, "uuid_catalog": {}}
else:
return_catalog = {"displayname_catalog": {}, "uuid_catalog": {}}
return (simplejson.dumps(return_catalog), 200)
return ("", simplejson.dumps(return_catalog), 200)
# ----------------------------
......
PROJECTS="\
snf-common\
snf-webproject\
astakosclient\
snf-django-lib\
snf-astakos-app\
snf-astakos-client\
snf-pithos-backend\
snf-cyclades-gtools\
snf-cyclades-app\
......
......@@ -41,7 +41,8 @@ from stat import S_IFDIR, S_IFREG
from sys import argv
from time import time
from synnefo.lib.parsedate import parse_http_date
from snf_django.lib.api.parsedate import parse_http_date
from pithos.tools.lib.client import OOS_Client, Fault
from pithos.tools.lib.fuse import FUSE, FuseOSError, Operations
......
......@@ -96,7 +96,7 @@ class Command(object):
if email_re.match(self.user):
try:
from synnefo.lib.astakos import get_user_uuid
from snf_django.lib.astakos import get_user_uuid
from pithos.api.settings import SERVICE_TOKEN
self.user = get_user_uuid(SERVICE_TOKEN, self.user)
except ImportError:
......
......@@ -19,5 +19,7 @@
version_file = "snf-quotaholder-app/quotaholder_django/version.py"
[[snf-stats-app]]
version_file = "snf-stats-app/synnefo_stats/version.py"
[[snf-astakos-client]]
version_file = "snf-astakos-client/astakosclient/version.py"
[[python-astakosclient]]
version_file = "astakosclient/astakosclient/version.py"
[[snf-django-lib]]
version_file = "snf-django-lib/snf_django/version.py"
......@@ -3,8 +3,10 @@ Changelog
v0.14.0
------
(* Unreleased *)
* settings *PITHOS_BACKEND_POOL_SIZE*
* setting *PITHOS_UPDATE_MD5* is set to False by default
* Remove PITHOS_AUTHENTICATION_USERS setting
v0.13.0
------
......
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