Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/markitobonito/cloud_repositorio/llms.txt

Use this file to discover all available pages before exploring further.

Cloud Repositorio uses a YAML file (database.yaml) as its persistent state store. It holds user accounts, slice topology, worker registrations, and auto-increment ID counters. The file is loaded at startup into memory and saved back to disk on every write operation, so the on-disk file always reflects the latest committed state.

File location

The default path is database.yaml in the working directory — wherever you launch the manager from. To use a different path, pass the filepath parameter when constructing the Database class:
from database import Database

db = Database(filepath="/etc/cloud_repositorio/state.yaml")

Top-level structure

The complete structure of database.yaml with annotations:
workers_list: ["10.0.10.1", "10.0.10.2", "10.0.10.3"]  # Worker IPs for discovery

users:                  # User accounts
  admin:
    username: admin
    password_hash: ...  # SHA-256 of password
    quota_vms: 10       # Max VMs this user can own
    used_vms: 0         # Current VM count
    slices: []          # List of slice IDs

workers:                # Populated at startup by WorkerDiscovery
  10.0.10.1:
    max_vms: 10
    max_cores: 2
    max_ram_gb: 1
    max_disk_gb: 500
    used_cores: 0
    used_ram_gb: 0
    used_disk_gb: 0

slices: {}              # Slice data keyed by slice_id (string)
next_vm_id: 1000        # Auto-increment counter for VM and slice IDs
next_vlan_id: 100       # Auto-increment counter (legacy, not actively used)

Adding users

There is no CLI command to add users. You must edit database.yaml directly. Generate a SHA-256 password hash in Python:
import hashlib
hashlib.sha256("mypassword".encode()).hexdigest()
Then add the new user block under users: with the resulting hash. For example, the default admin password hash:
8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
corresponds to the password admin. Change this before deploying to any non-test environment. A complete user entry looks like:
users:
  alice:
    username: alice
    password_hash: <sha256-hash>
    quota_vms: 6
    used_vms: 0
    slices: []

Quota management

quota_vms limits the total number of VMs a user can add across all of their slices. The check in OrchestratorAPI.add_vm_to_slice() is:
if (user.get("used_vms", 0) + 1) > user.get("quota_vms", 10):
    return False, "Quota exceeded"
Setting quota_vms to 0 effectively disables the account — no VMs can be created. Default values are:
Userquota_vms
admin10
student6
used_vms is incremented automatically when a VM is added and decremented when a slice is deleted. Do not modify it manually unless you are correcting drift after a failed operation.

Thread safety

The Database class uses threading.RLock to protect all write operations. Every method that mutates self.data acquires the lock before calling save():
def update_slice(self, slice_id, slice_dict):
    with self.lock:
        self.data["slices"][str(slice_id)] = slice_dict
        self.save()
This ensures that concurrent slice deployments — which may update user quotas and slice state simultaneously — do not corrupt the YAML file.
Manually editing database.yaml while the manager is running can cause data loss. The in-memory state takes precedence and will overwrite your changes on the next write operation. Always stop the manager before editing the file directly.

Build docs developers (and LLMs) love