dtool lookup server plugin for receiving elastic-search update notifications
Project description
GitHub: https://github.com/livMatS/dtool-lookup-server-notification-plugin
PyPI: https://pypi.python.org/pypi/dtool-lookup-server-notification-plugin
Free software: MIT License
Features
Listen to elastic search notifications from an S3-compatible storage backend
Listen to S3 event notifications from an S3-compatible storage backend
Introduction
dtool is a command line tool for packaging data and metadata into a dataset. A dtool dataset manages data and metadata without the need for a central database.
However, if one has to manage more than a hundred datasets it can be helpful to have the datasets’ metadata stored in a central server to enable one to quickly find datasets of interest.
The dtool-lookup-server provides a web API for registering datasets’ metadata and provides functionality to lookup, list and search for datasets.
This plugin enables the dtool-lookup-server to listen to notifications for the registration and deregistration of datasets.
Installation
Install the dtool lookup server dependency graph plugin
$ pip install dtool-lookup-server-notification-plugin
Setup and configuration
Configure plugin behavior
The plugin needs to know how to convert a bucket name into a base URI. The environment variable DTOOL_LOOKUP_SERVER_NOTIFY_BUCKET_TO_BASE_URI is used to specify that conversion, e.g.:
DTOOL_LOOKUP_SERVER_NOTIFY_BUCKET_TO_BASE_URI={"bucket": "ecs://bucket"}
It is also advisable to limit access to the notification listener to a certain IP range. Use:
DTOOL_LOOKUP_SERVER_NOTIFY_ALLOW_ACCESS_FROM=192.168.0.0/16
to specify the allowed remote network. To specify a single IP, use:
DTOOL_LOOKUP_SERVER_NOTIFY_ALLOW_ACCESS_FROM=192.168.1.1/32
Configure elastic search integration in NetApp StorageGRID
Create a new endpoint with URI https://myserver:myport/elastic-search and URN arn:<mysite>:es:::<domain-name>/notify/all
Note that <mysite> and <domain-name> can be chose arbitrarily. notify/all is appended to the URI and must point to the route of the notify function.
The bucket needs to be configured to support search integration. Use the following XML template
<MetadataNotificationConfiguration>
<Rule>
<ID>dtool</ID>
<Status>Enabled</Status>
<Prefix></Prefix>
<Destination>
<Urn>urn:mysite:es:::domain-name/notify/all</Urn>
</Destination>
</Rule>
</MetadataNotificationConfiguration>
Configure webhook in minio
The Publish Events to Webhook minio docs walks through the configuration for sending S3 event notifications to a webhook. Assuming a dtool-lookup-server with this plugin activated running at http://dtool-lookup-server:5000, and your minio instance with a bucket test-bucket at https://s3server:9000, use
# mc: minio client
mc config host add s3server http://s3server:9000 {admin_user} {admin_password}
# Note that the endpoint must be reachable when configuring, otherwise minio will reject
mc admin config set s3server/ notify_webhook:dtool endpoint="http://dtool-lookup-server:5000/webhook/notify"
mc admin service restart s3server # restart is necessary
# Activate the actual notifications
mc event add s3server/test-bucket arn:minio:sqs::testbucket:dtool --event "put,delete"
to configure a webhook endpoint identified by dtool and activate put and delete event notification. Choose the parameters for --event "put,delete" from minio’s Supported Bucket Evenets.
Note that minio is very strict on whom they talk to. If your dtool-lookup-server communicates via https, make sure that the server certificate uses SANs and that the signing authority’s root certificate is available to minio. See Install Certificates from Third-party CAs in the minio docs. Also assure all services are reachable by valid hostnames. Within a containerized environment such as launched with docker-compose , host names containing underscores _ may occur, but minio refuses to speak with such.
Configure webhook in NetApp StorageGRID
NetAPP StorageGRID is able to submit S3 event notifications when configured to communicate with an SNS endpoint, refer to the according sections of the NetApp StorageGRID docs for creating service endpoints and configuring event notifications.
In short, create an endpoint `http://dtool-lookup-server:5000/webhook/notify` with a suitable URN, i.e. urn:dtool-lookup-server:sns:region:notify:all, where you may pick all fields freely except urn and sns.
Next, enable event notifications for the desired bucket, i.e. for object creation events with a policy snippet like this:
<NotificationConfiguration>
<TopicConfiguration>
<Id>Object created</Id>
<Topic>urn:dtool-lookup-server:sns:region:notify:all</Topic>
<Event>s3:ObjectCreated:*</Event>
</TopicConfiguration>
</NotificationConfiguration>
Querying server plugin configuration
The request
$ curl -H "$HEADER" http://localhost:5000/elastic-search/config
will return the current notification plugin configuration with all keys in lowercase
{
"allow_access_from": "0.0.0.0/0",
"bucket_to_base_uri": {"bucket": "s3://bucket"},
"version": "0.1.0"
}
See dtool_lookup_server_dependency_graph_plugin.config.Config for more information.
Testing
Launch a minimal mongodb instance with
$ cd tests/container && docker-compose up -d
and run tests from within repository root using
pytest --log-cli-level=DEBUG
Refer to .github/workflows/test.yml for the recommended testing environment.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dtool-lookup-server-notification-plugin-0.2.2.tar.gz
.
File metadata
- Download URL: dtool-lookup-server-notification-plugin-0.2.2.tar.gz
- Upload date:
- Size: 47.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 267eac4b165c63c431928820ba2c902bfcf7aec12d33fe60b1e5ef2988cef517 |
|
MD5 | 10a72f263df554da3d74f79cad5761d4 |
|
BLAKE2b-256 | fe06d6ce77eeace20bbdbda577f149e71960ff329d4b1d86fd14658c5ef57e68 |
File details
Details for the file dtool_lookup_server_notification_plugin-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: dtool_lookup_server_notification_plugin-0.2.2-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d1e151c9b1da74792c05ae478902a807091b54fe3c15b3f64a7e817cbd1ec2f |
|
MD5 | ca69e94fdd4696fa74cec87051b3507b |
|
BLAKE2b-256 | 022be0fdf99404e5a63b6b00721dc0c89a2f2fb50cba120963a6a78f380dc265 |