This tool reads the federation.json, queries each server’s .well-known/ocm endpoint, and produces an ocmproviders.json file compatible with ScienceMesh or other Reva based integrations.
Find a file
2025-10-12 20:07:45 +00:00
src add: initial commit 2025-10-12 20:07:45 +00:00
.gitignore add: initial commit 2025-10-12 20:07:45 +00:00
Cargo.lock add: initial commit 2025-10-12 20:07:45 +00:00
Cargo.toml add: initial commit 2025-10-12 20:07:45 +00:00
LICENSE.md add: initial commit 2025-10-12 20:07:45 +00:00
README.md add: initial commit 2025-10-12 20:07:45 +00:00
rust-toolchain add: initial commit 2025-10-12 20:07:45 +00:00

Federation List to OCM Providers Converter

A command-line tool that converts a federation.json file into an ocmproviders.json file, dynamically discovering each provider's OCM and WebDAV endpoints via the .well-known/ocm endpoint when available.


Overview

This tool reads the federation.json, queries each server's .well-known/ocm endpoint, and produces an ocmproviders.json file compatible with ScienceMesh or other Reva based integrations.

If a .well-known/ocm endpoint cannot be reached or does not return valid JSON, the tool falls back to default paths:

  • OCM: /ocm
  • WebDAV: /dav

Features

  • Fetches .well-known/ocm dynamically for accurate endpoint discovery
  • Extracts both:
    • endPoint (OCM API)
    • protocols.webdav (WebDAV API)
  • Graceful fallback to defaults on failure
  • Merges with existing ocmproviders.json unless --overwrite is used

Installation

Ensure you have Rust and Cargo installed.
Then clone and build the project:

git clone https://git.azadehafzar.io/open-cloud-mesh/federation-to-providers
cd federation-to-providers
cargo build --release

The compiled binary will be available at:

target/release/federation-to-providers

Usage

Basic Command

./federation-to-providers -i federation.json -o ocmproviders.json

This reads the federation.json, adds any new providers not already present in ocmproviders.json, and saves the updated list.

Overwrite Output

./federation-to-providers -i federation.json -o ocmproviders.json --overwrite

Replaces any existing ocmproviders.json file entirely.

Example

Input

federation.json:

{
  "federation": "EOSC federation",
  "servers": [
    {
      "displayName": "CERNBox",
      "url": "https://qa.cernbox.cern.ch"
    },
    {
      "displayName": "ownCloud",
      "url": "https://oc.example.org"
    }
  ]
}

Output

ocmproviders.json:

[
  {
    "name": "CERNBox",
    "full_name": "CERNBox test provider 1",
    "organization": "CERNBox",
    "domain": "qa.cernbox.cern.ch",
    "homepage": "https://qa.cernbox.cern.ch",
    "description": "CERNBox testing",
    "services": [
      {
        "endpoint": {
          "type": {
            "name": "OCM",
            "description": "CERNBox Open Cloud Mesh API"
          },
          "name": "CERNBox - OCM API",
          "path": "https://qa.cernbox.cern.ch/ocm",
          "is_monitored": true
        },
        "api_version": "0.0.1",
        "host": "qa.cernbox.cern.ch"
      },
      {
        "endpoint": {
          "type": {
            "name": "Webdav",
            "description": "CERNBox Webdav API"
          },
          "name": "CERNBox Example - Webdav API",
          "path": "https://qa.cernbox.cern.ch/remote.php/dav/ocm",
          "is_monitored": true
        },
        "api_version": "0.0.1",
        "host": "https://qa.cernbox.cern.ch"
      }
    ]
  }
]

Error Handling

  • If .well-known/ocm is missing or invalid, default paths are used
  • HTTP timeouts are set to 5 seconds per server
  • Invalid JSON or HTTP errors do not stop the process; the provider is still included with fallback values