mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-08 17:22:11 +08:00
Enhancement: support multiple proxmox nodes (#5539)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -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