Enhancement: support multiple proxmox nodes (#5539)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
dNhax
2025-09-04 10:49:41 +02:00
committed by GitHub
parent 7b60a60d4e
commit 65dce6d387
3 changed files with 31 additions and 9 deletions

View File

@@ -4,11 +4,13 @@ description: Proxmox Configuration
--- ---
The Proxmox connection is configured in the `proxmox.yaml` file. See [Create token](#create-token) section below for details on how to generate the required API token. The Proxmox connection is configured in the `proxmox.yaml` file. See [Create token](#create-token) section below for details on how to generate the required API token.
You can configure multiple nodes - be sure to use the exact `proxmoxNode` identifier!
```yaml ```yaml
url: https://proxmox.host.or.ip:8006 pve:
token: username@pam!Token ID url: https://proxmox.host.or.ip:8006
secret: secret token: username@pam!Token ID
secret: secret
``` ```
## Services ## Services
@@ -17,7 +19,7 @@ Once the Proxmox connection is configured, individual services can be configured
### Configuration Options ### Configuration Options
- `proxmoxNode`: The name of the Proxmox node where your VM/LXC is running - `proxmoxNode`: The name of the Proxmox node where your VM/LXC is running, must match with a node configured in the `proxmox.yaml`
- `proxmoxVMID`: The ID of the Proxmox VM or LXC container - `proxmoxVMID`: The ID of the Proxmox VM or LXC container
- `proxmoxType`: (Optional) The type of Proxmox virtual machine. Defaults to `qemu` for VMs, but can be set to `lxc` for LXC containers - `proxmoxType`: (Optional) The type of Proxmox virtual machine. Defaults to `qemu` for VMs, but can be set to `lxc` for LXC containers

View File

@@ -24,9 +24,28 @@ export default async function handler(req, res) {
}); });
} }
const baseUrl = `${proxmoxConfig.url}/api2/json`; // Prefer per-node config (new format), fall back to legacy flat creds.
const nodeConfig =
(node && proxmoxConfig && proxmoxConfig[node]) ||
(proxmoxConfig && proxmoxConfig.url && proxmoxConfig.token && proxmoxConfig.secret
? {
url: proxmoxConfig.url,
token: proxmoxConfig.token,
secret: proxmoxConfig.secret,
}
: null);
if (!nodeConfig) {
return res.status(400).json({
error:
"Proxmox config not found for the specified node and no legacy credentials detected. " +
"Add a node block in proxmox.yaml (e.g., 'pve: { url, token, secret }') or restore legacy top-level url/token/secret.",
});
}
const baseUrl = `${nodeConfig.url}/api2/json`;
const headers = { const headers = {
Authorization: `PVEAPIToken=${proxmoxConfig.token}=${proxmoxConfig.secret}`, Authorization: `PVEAPIToken=${nodeConfig.token}=${nodeConfig.secret}`,
}; };
const statusUrl = `${baseUrl}/nodes/${node}/${vmType}/${vmid}/status/current`; const statusUrl = `${baseUrl}/nodes/${node}/${vmType}/${vmid}/status/current`;

View File

@@ -1,4 +1,5 @@
--- ---
# pve:
# url: https://proxmox.host.or.ip:8006 # url: https://proxmox.host.or.ip:8006
# token: username@pam!Token ID # token: username@pam!Token ID
# secret: secret # secret: secret