diff --git a/PKG-INFO b/PKG-INFO index 70619f9..29779b4 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,10 +1,10 @@ Metadata-Version: 1.0 Name: swh.vault -Version: 0.0.1 +Version: 0.0.2 Summary: Software Heritage vault Home-page: https://forge.softwareheritage.org/diffusion/DVAU/ Author: Software Heritage developers Author-email: swh-devel@inria.fr License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN diff --git a/PKG-INFO b/swh.vault.egg-info/PKG-INFO similarity index 94% copy from PKG-INFO copy to swh.vault.egg-info/PKG-INFO index 70619f9..29779b4 100644 --- a/PKG-INFO +++ b/swh.vault.egg-info/PKG-INFO @@ -1,10 +1,10 @@ Metadata-Version: 1.0 Name: swh.vault -Version: 0.0.1 +Version: 0.0.2 Summary: Software Heritage vault Home-page: https://forge.softwareheritage.org/diffusion/DVAU/ Author: Software Heritage developers Author-email: swh-devel@inria.fr License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN diff --git a/swh.vault.egg-info/SOURCES.txt b/swh.vault.egg-info/SOURCES.txt new file mode 100644 index 0000000..e5dee1f --- /dev/null +++ b/swh.vault.egg-info/SOURCES.txt @@ -0,0 +1,46 @@ +.gitignore +AUTHORS +LICENSE +MANIFEST.in +Makefile +requirements-swh.txt +requirements.txt +setup.py +version.txt +debian/changelog +debian/compat +debian/control +debian/copyright +debian/rules +debian/source/format +docs/.gitignore +docs/Makefile +docs/conf.py +docs/index.rst +docs/vault-blueprint.md +docs/_static/.placeholder +docs/_templates/.placeholder +sql/swh-vault-schema.sql +swh/__init__.py +swh.vault.egg-info/PKG-INFO +swh.vault.egg-info/SOURCES.txt +swh.vault.egg-info/dependency_links.txt +swh.vault.egg-info/not-zip-safe +swh.vault.egg-info/requires.txt +swh.vault.egg-info/top_level.txt +swh/vault/__init__.py +swh/vault/backend.py +swh/vault/cache.py +swh/vault/cooking_tasks.py +swh/vault/api/__init__.py +swh/vault/api/client.py +swh/vault/api/server.py +swh/vault/cookers/__init__.py +swh/vault/cookers/base.py +swh/vault/cookers/directory.py +swh/vault/cookers/revision_flat.py +swh/vault/cookers/revision_gitfast.py +swh/vault/tests/test_backend.py +swh/vault/tests/test_cache.py +swh/vault/tests/test_cookers.py +swh/vault/tests/vault_testing.py \ No newline at end of file diff --git a/swh.vault.egg-info/dependency_links.txt b/swh.vault.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/swh.vault.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/swh.vault.egg-info/not-zip-safe b/swh.vault.egg-info/not-zip-safe new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/swh.vault.egg-info/not-zip-safe @@ -0,0 +1 @@ + diff --git a/swh.vault.egg-info/requires.txt b/swh.vault.egg-info/requires.txt new file mode 100644 index 0000000..b5e5e9f --- /dev/null +++ b/swh.vault.egg-info/requires.txt @@ -0,0 +1,11 @@ +click +fastimport +flask +psycopg2 +python-dateutil +swh.core>=0.0.28 +swh.model>=0.0.18 +swh.objstorage>=0.0.17 +swh.scheduler>=0.0.11 +swh.storage>=0.0.92 +vcversioner diff --git a/swh.vault.egg-info/top_level.txt b/swh.vault.egg-info/top_level.txt new file mode 100644 index 0000000..0cb0f8f --- /dev/null +++ b/swh.vault.egg-info/top_level.txt @@ -0,0 +1 @@ +swh diff --git a/swh/vault/api/server.py b/swh/vault/api/server.py index 88b7079..d6625f0 100644 --- a/swh/vault/api/server.py +++ b/swh/vault/api/server.py @@ -1,172 +1,177 @@ # Copyright (C) 2016 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import asyncio import aiohttp.web import click from swh.core import config from swh.core.api_async import (SWHRemoteAPI, encode_data_server as encode_data, decode_request) from swh.model import hashutil from swh.vault.cookers import COOKER_TYPES from swh.vault.backend import VaultBackend +DEFAULT_CONFIG_PATH = 'vault/server' DEFAULT_CONFIG = { 'storage': ('dict', { 'cls': 'local', 'args': { 'db': 'dbname=softwareheritage-dev', 'objstorage': { 'cls': 'pathslicing', 'args': { 'root': '/srv/softwareheritage/objects', 'slicing': '0:2/2:4/4:6', }, }, }, }), 'cache': ('dict', { 'cls': 'pathslicing', 'args': { 'root': '/srv/softwareheritage/vault', 'slicing': '0:1/1:5', }, }), 'db': ('str', 'dbname=swh-vault') } @asyncio.coroutine def index(request): return aiohttp.web.Response(body="SWH Vault API server") # Web API endpoints @asyncio.coroutine def vault_fetch(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] if not request.app['backend'].is_available(obj_type, obj_id): raise aiohttp.web.HTTPNotFound return encode_data(request.app['backend'].fetch(obj_type, obj_id)) def user_info(task_info): return {'task_uuid': str(task_info['task_uuid']), 'status': task_info['task_status'], 'progress_message': task_info['progress_msg'], 'obj_type': task_info['type'], 'obj_id': hashutil.hash_to_hex(task_info['object_id'])} @asyncio.coroutine def vault_cook(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] email = request.query.get('email') sticky = request.query.get('sticky') in ('true', '1') if obj_type not in COOKER_TYPES: raise aiohttp.web.HTTPNotFound info = request.app['backend'].cook_request(obj_type, obj_id, email=email, sticky=sticky) # TODO: return 201 status (Created) once the api supports it return encode_data(user_info(info)) @asyncio.coroutine def vault_progress(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] info = request.app['backend'].task_info(obj_type, obj_id) if not info: raise aiohttp.web.HTTPNotFound return encode_data(user_info(info)) # Cookers endpoints @asyncio.coroutine def set_progress(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] progress = yield from decode_request(request) request.app['backend'].set_progress(obj_type, obj_id, progress) return encode_data(True) # FIXME: success value? @asyncio.coroutine def set_status(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] status = yield from decode_request(request) request.app['backend'].set_status(obj_type, obj_id, status) return encode_data(True) # FIXME: success value? @asyncio.coroutine def put_bundle(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] # TODO: handle streaming properly content = yield from decode_request(request) request.app['backend'].cache.add(obj_type, obj_id, content) return encode_data(True) # FIXME: success value? @asyncio.coroutine def send_notif(request): obj_type = request.match_info['type'] obj_id = request.match_info['id'] request.app['backend'].send_all_notifications(obj_type, obj_id) return encode_data(True) # FIXME: success value? # Web server def make_app(config, **kwargs): app = SWHRemoteAPI(**kwargs) app.router.add_route('GET', '/', index) # Endpoints used by the web API app.router.add_route('GET', '/fetch/{type}/{id}', vault_fetch) app.router.add_route('POST', '/cook/{type}/{id}', vault_cook) app.router.add_route('GET', '/progress/{type}/{id}', vault_progress) # Endpoints used by the Cookers app.router.add_route('POST', '/set_progress/{type}/{id}', set_progress) app.router.add_route('POST', '/set_status/{type}/{id}', set_status) app.router.add_route('POST', '/put_bundle/{type}/{id}', put_bundle) app.router.add_route('POST', '/send_notif/{type}/{id}', send_notif) app['backend'] = VaultBackend(config) return app +def make_app_from_configfile(config_path=DEFAULT_CONFIG_PATH, **kwargs): + return make_app(config.read(config_path, DEFAULT_CONFIG), **kwargs) + + @click.command() @click.argument('config-path', required=1) @click.option('--host', default='0.0.0.0', help="Host to run the server") @click.option('--port', default=5005, type=click.INT, help="Binding port of the server") @click.option('--debug/--nodebug', default=True, help="Indicates if the server should run in debug mode") def launch(config_path, host, port, debug): app = make_app(config.read(config_path, DEFAULT_CONFIG), debug=bool(debug)) aiohttp.web.run_app(app, host=host, port=int(port)) if __name__ == '__main__': launch() diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..bf3e52e --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +v0.0.2-0-g203fa3f \ No newline at end of file