Skip to content

Instantly share code, notes, and snippets.

@groundnuty
Last active February 27, 2018 10:33
Show Gist options
  • Save groundnuty/c6c3fdbe6e4120827e072c2c8f52d05a to your computer and use it in GitHub Desktop.
Save groundnuty/c6c3fdbe6e4120827e072c2c8f52d05a to your computer and use it in GitHub Desktop.
Onedata replications cheatsheet

Envs we will need

OZ_HOST="90.147.170.26"

TOKEN='MDAxNWxvY2F00aW9uIG9uZXpvbmUKMDAzYmlkZW500aWZpZXIga3c00QXExOTJQUXd4SHRyalBxcXlFS1NWWldSeVM3bHFaSWVDTHVQQVZaNAowMDFhY2lkIHRpbWUgPCAxNTM3NDUwNjkzCjAwMmZzaWduYXR1cmUgIh2n5CILKKXUbtEZC01tmQzQEgcq27gnTWV0102J6WMzegK'

SPACEID="S-HHji1RCFgGlGsTJ4kZ23Jiu6vhvVI74PRaGLuJSVg"

HOST="oneprovider.cesnet.cz"
PROVIDER_TO_REPLICATE_TO="cyfronet-oneprovider-10.tk"

Get user spaces ids

curl -u admin:password -k -X GET https://$OZ_HOST:8443/api/v3/onezone/user/spaces

Stream of changes

curl --tlsv1.2 -N -X GET -H "X-Auth-Token: $TOKEN" "https://$HOST:8443/api/v3/oneprovider/changes/metadata/$SPACEID"

Example change for uploaded file

{"seq":113,"name":"HG00101.chrom20.ILLUMINA.bwa.GBR.low_coverage.20130415.bam.bai","file_path":"/data/HG00101.chrom20.ILLUMINA.bwa.GBR.low_coverage.20130415.bam.bai","file_id":"00000000005CD913677569642350764D3856467067684D45357363344F7A72303565646663716C514E61555A395761364A484D797150557723532D48486A693152434667476C4773544A346B5A32334A69753676687656493734505261474C754A535667","deleted":false,"changes":{"xattrs":{},"version":0,"uid":"780c850e209d2f7a18f1ba3c150b5192","type":"REG","size":180800,"scope":"S-HHji1RCFgGlGsTJ4kZ23Jiu6vhvVI74PRaGLuJSVg","mtime":1505915279,"mode":436,"is_scope":false,"ctime":1505915279,"atime":1505915279}}

We need to filter steam of changes. Lets get all created and changed files

curl --tlsv1.2 -N -X GET -H "X-Auth-Token: $TOKEN" "https://$HOST:8443/api/v3/oneprovider/changes/metadata/$SPACEID" | jq -r ".deleted" | grep -v false 

Get details of privder we to replicate to:

curl -u admin:MqTNRZ6SoWYJl -k -X GET   https://${PROVIDER_TO_REPLICATE_TO}:9443/api/v3/onepanel/provider 

Example response:

{"id":"pWbiI2Purs9iHiZfqbKIndfb2dli7IxL6tVMD3pXsyg","name":"Beijing","redirectionPoint":"https://cyfronet-oneprovider-10.tk","urls":["149.156.10.224"],"geoLatitude":39.91666667,"geoLongitude":116.383333}%

Replicate a file named Dockerfile present on $HOST provider to $PROVIDER_TO_REPLICATE_TO

Upload an example file called 'Dockerfile' to a root of a space. And replicate it to another provider.

curl --tlsv1.2 -X POST -H "X-Auth-Token: $TOKEN" -H 'Content-type: application/json' "https://$HOST:8443/api/v3/oneprovider/replicas/data/Dockerfile?provider_id=pWbiI2Purs9iHiZfqbKIndfb2dli7IxL6tVMD3pXsyg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment