Files
Proxmox-VPS-Panel/backend/app/proxmox_client.py
T
2026-07-25 02:20:37 +03:00

20 lines
1017 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
def get_vnc_ticket(guest_type: str, vmid: int, node: str = None) -> dict:
"""Запрашивает у Proxmox одноразовый тикет для VNC/websocket-консоли.
Возвращаемый тикет привязан к origin (схема+хост+порт), через который
был сделан запрос к Proxmox. В Proxmox 8.x+ нет параметра host= для
vncproxy — тикет привязывается автоматически к тому origin, через
который backend подключён к Proxmox (т.е. к PVE_HOST).
"""
node = node or settings.pve_node
px = _client()
endpoint = px.nodes(node).qemu(vmid) if guest_type == "vm" else px.nodes(node).lxc(vmid)
result = endpoint.vncproxy.post(websocket=1)
return {
"ticket": result["ticket"],
"port": result["port"],
"node": node,
"vmid": vmid,
"guest_type": guest_type,
"pve_host": settings.pve_host,
}