mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-05 21:47:48 +01:00
Enhancement: support multiple proxmox nodes (#5539)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -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.
|
||||
You can configure multiple nodes - be sure to use the exact `proxmoxNode` identifier!
|
||||
|
||||
```yaml
|
||||
url: https://proxmox.host.or.ip:8006
|
||||
token: username@pam!Token ID
|
||||
secret: secret
|
||||
pve:
|
||||
url: https://proxmox.host.or.ip:8006
|
||||
token: username@pam!Token ID
|
||||
secret: secret
|
||||
```
|
||||
|
||||
## Services
|
||||
@@ -17,7 +19,7 @@ Once the Proxmox connection is configured, individual services can be configured
|
||||
|
||||
### 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
|
||||
- `proxmoxType`: (Optional) The type of Proxmox virtual machine. Defaults to `qemu` for VMs, but can be set to `lxc` for LXC containers
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
Authorization: `PVEAPIToken=${proxmoxConfig.token}=${proxmoxConfig.secret}`,
|
||||
Authorization: `PVEAPIToken=${nodeConfig.token}=${nodeConfig.secret}`,
|
||||
};
|
||||
|
||||
const statusUrl = `${baseUrl}/nodes/${node}/${vmType}/${vmid}/status/current`;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
# url: https://proxmox.host.or.ip:8006
|
||||
# token: username@pam!Token ID
|
||||
# secret: secret
|
||||
# pve:
|
||||
# url: https://proxmox.host.or.ip:8006
|
||||
# token: username@pam!Token ID
|
||||
# secret: secret
|
||||
|
||||
Reference in New Issue
Block a user