Dedup VMs across real Proxmox cluster nodes (was listing each VM once per entered host)
This commit is contained in:
+24
-1
@@ -153,7 +153,30 @@ ipcMain.handle('proxmox:login', async (_e, { host, username, password }) => {
|
||||
return { success: false, error: attempts[0].error };
|
||||
}
|
||||
|
||||
clients = succeeded;
|
||||
// Several hostnames can point at nodes of the SAME real Proxmox cluster
|
||||
// (e.g. Stefan's setup) — in that case /cluster/resources returns the
|
||||
// identical cluster-wide VM list from every one of them, so keeping all
|
||||
// logged-in clients would just show each VM 3x. Detect real cluster
|
||||
// membership and keep only one representative client per cluster.
|
||||
const seenGroups = new Set();
|
||||
const dedupedClients = [];
|
||||
await Promise.all(
|
||||
succeeded.map(async (entry) => {
|
||||
try {
|
||||
entry.clusterId = await entry.client.getClusterId();
|
||||
} catch {
|
||||
entry.clusterId = null;
|
||||
}
|
||||
})
|
||||
);
|
||||
for (const entry of succeeded) {
|
||||
const group = entry.clusterId || `standalone:${entry.host}`;
|
||||
if (seenGroups.has(group)) continue;
|
||||
seenGroups.add(group);
|
||||
dedupedClients.push(entry);
|
||||
}
|
||||
|
||||
clients = dedupedClients;
|
||||
createWindow('vms.html', 680, 520, true);
|
||||
|
||||
if (failed.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user