r2lab-api
REST API for the R2lab wireless testbed: it manages
users, slices, leases, and registrations. The code is in
https://
For authentication, day-to-day operations, database backups and upgrades, see the operating guide.
Development¶
git clone git@github.com:fit-r2lab/r2lab-api.git
cd r2lab-api
uv venv && uv sync
cp deploy/.env.example .env # edit as needed (set R2LAB_MAIL_MODE=console for dev)
alembic upgrade head
uvicorn r2lab_api.app:app --reload --port 9999API docs at https://
Tests¶
pytestTests use an in-memory SQLite database — no PostgreSQL needed.
Deployment¶
The API runs on a Fedora VM (r2labapi.inria.fr) as a systemd service.
The code lives in /root/r2lab-api/ (git clone, no RPM).
First-time setup¶
ssh root@r2labapi.inria.fr
git clone https://github.com/fit-r2lab/r2lab-api.git /root/r2lab-api
cd /root/r2lab-api
deploy/setup.sh path/to/r2lab.pgdumpThis installs PostgreSQL, Python, creates the venv, restores the database, and enables the systemd services.
After setup, review and adjust /root/r2lab-api/.env (see .env.example for reference).
Deploying code updates¶
Normally there is nothing to do: auto-update pulls the
repo and runs deploy/update.sh, which syncs the venv and restarts the service;
database migrations are applied when the service starts. By hand:
cd /root/r2lab-api
git pull
.venv/bin/alembic upgrade head # only if there are new migrations
systemctl restart r2lab-apiFiles in deploy/¶
| File | What it does |
|---|---|
r2lab-api.service | Systemd unit for the API (uvicorn on local port 9999) |
r2lab-backup.service | Oneshot that runs pg_dump |
r2lab-backup.timer | Triggers the backup every hour |
r2lab-slice-warning.service | Oneshot that warns members of soon-to-expire slices |
r2lab-slice-warning.timer | Triggers the slice-expiry warning once a day |
.env.example | Template for production configuration |
setup.sh | First-time setup script |
restore-db.sh | Restore database from a pgdump file |
pg-upgrade.sh | Dump/restore helper for PostgreSQL major upgrades |