The 'DCM Transfer Module'-API provides functionality to transfer Submission Information Packages (SIPs) from the shared file storage to a remote server.
This repository contains the corresponding Flask app definition.
For the associated OpenAPI-document, please refer to the sibling package dcm-transfer-module-api
.
The contents of this repository are part of the Digital Curation Manager
.
Make sure to include the extra-index-url https://zivgitlab.uni-muenster.de/api/v4/projects/9020/packages/pypi/simple
in your pip-configuration to enable an automated install of all dependencies.
Using a virtual environment is recommended.
- Install with
pip install .
- Configure service environment to fit your needs (see here).
- Run app as
flask run --port=8080
- To manually use the API, either run command line tools like
curl
as, e.g.,or run a gui-application, like Swagger UI, based on the OpenAPI-document provided in the sibling packagecurl -X 'POST' \ 'http://localhost:8080/transfer' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "transfer": { "target": { "path": "jobs/abcde-12345-fghijk-67890" } } }'
dcm-transfer-module-api
.
Simply run
docker compose up
By default, the app listens on port 8080.
The docker volume file_storage
is automatically created and data will be written in /file_storage
.
To rebuild an already existing image, run docker compose build
.
Additionally, a Swagger UI is hosted at
http://localhost/docs
Additionally, an OpenSSH-server with pre-installed rsync
is started (listening on port 2222
).
This server is configured for authentication with both username+password (foo
+pass
) or via ssh-key (username foo
).
The corresponding private key is located in test_dcm_transfer_module/fixtures/.ssh/id_rsa
(it may be required to set file permissions as chmod 600 test_dcm_transfer_module/fixtures/.ssh/id_rsa
after cloning this repository).
The openssh-server mounts the test_dcm_transfer_module/remote_storage
-directory to work with (mount source location is chosen due to its use in automated tests).
Test connection via ssh with
ssh -i test_dcm_transfer_module/fixtures/.ssh/id_rsa -p 2222 foo@localhost
or run rsync
as
rsync -v -e "ssh -i test_dcm_transfer_module/fixtures/.ssh/id_rsa -p 2222" README.md foo@localhost:/remote_storage/README.md
Afterwards, stop the process and enter docker compose down
.
Install additional dev-dependencies with
pip install -r dev-requirements.txt
Run unit-tests with
pytest -v -s
In order for the full test suite to run, the OpenSSH-server defined in compose.yml
needs to be available.
Furthermore, the directory test_dcm_transfer_module/remote_storage
needs to exist and have correct permissions
mkdir -m 777 test_dcm_transfer_module/remote_storage
The server can be started with
docker compose run -i -T -p 2222:2222 openssh-server
Service-specific environment variables are
LOCAL_TRANSFER
[DEFAULT 0]: whether to perform only local file transferSSH_HOSTNAME
[DEFAULT "localhost"]: hostname of the remote machineSSH_PORT
[DEFAULT 22]: port of the ssh-server on remote machineSSH_HOST_PUBLIC_KEY
[DEFAULT None]: public key of the remote machine (requiresSSH_HOST_PUBLIC_KEY_ALGORITHM
)SSH_HOST_PUBLIC_KEY_ALGORITHM
[DEFAULT None]: algorithm for public key of the remote machine (requiresSSH_HOST_PUBLIC_KEY
)SSH_BATCH_MODE
[DEFAULT 1]: whether to use batch mode (disable prompting) for ssh-commandsSSH_USERNAME
[DEFAULT "dcm"]: username for ssh-connection to remote machineSSH_IDENTITY_FILE
[DEFAULT "~/.ssh/id_rsa"]: path to private key file for ssh-connection to remote machineSSH_CLIENT_OPTIONS
[DEFAULT []]: JSON array with additional options that are passed to sshREMOTE_DESTINATION
[DEFAULT "/remote_storage"]: destination directory on remote machineOVERWRITE_EXISTING
[DEFAULT 0]: whether to overwrite existing files on remote machineUSE_COMPRESSION
[DEFAULT 0]: whether to use compression for transferCOMPRESSION_LEVEL
[DEFAULT None]: level of compression (seersync --compress-level ...
)VALIDATE_CHECKSUMS
[DEFAULT 0]: whether to validate checksums for transferred filesTRANSFER_TIMEOUT
[DEFAULT 3]: connection timeout in secondsTRANSFER_RETRIES
[DEFAULT 3]: number of retries for failed transfersTRANSFER_RETRY_INTERVAL
[DEFAULT 360]: interval between retries in secondsTRANSFER_OPTIONS
[DEFAULT []]: JSON array with additional options that are passed to rsync
Additionally this service provides environment options for
BaseConfig
,OrchestratedAppConfig
, andFSConfig
as listed here.
- Sven Haubold
- Orestis Kazasidis
- Stephan Lenartz
- Kayhan Ogan
- Michael Rahier
- Steffen Richters-Finger
- Malte Windrath
- Roman Kudinov