Prepara l'architettura multi-nodo (MediaMTX+ffmpeg) con assignment URL per sessione, admin di provision/drain e provider Cloud/DNS astratti verso mltv-stream.net. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.3 KiB
Ruby
46 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Streams
|
|
module CloudProviders
|
|
# Lab senza API Proxmox: simula create/destroy e riusa MediaMTX home per i path.
|
|
# Utile per testare registry, assignment e admin senza secondi host.
|
|
class LocalLab < Base
|
|
def create_node(name:, labels: {})
|
|
Instance.new(
|
|
id: "sim-#{name}",
|
|
name: name,
|
|
public_ip: labels[:public_ip].presence || "127.0.0.1",
|
|
private_ip: labels[:private_ip].presence || "127.0.0.1",
|
|
status: "running",
|
|
raw: { simulated: true, labels: labels }
|
|
)
|
|
end
|
|
|
|
def destroy_node(instance_id)
|
|
true
|
|
end
|
|
|
|
def list_nodes(labels: {})
|
|
StreamNode.where(provider: "local", role: "lab").map do |node|
|
|
Instance.new(
|
|
id: node.provider_instance_id,
|
|
name: node.slug,
|
|
public_ip: node.metadata["public_ip"],
|
|
private_ip: node.metadata["private_ip"],
|
|
status: node.status == "ready" ? "running" : node.status,
|
|
raw: node.metadata
|
|
)
|
|
end
|
|
end
|
|
|
|
def wait_until_running(instance_id, timeout: 120)
|
|
Instance.new(id: instance_id, name: instance_id, status: "running")
|
|
end
|
|
|
|
def public_ip(instance_id)
|
|
"127.0.0.1"
|
|
end
|
|
end
|
|
end
|
|
end
|