use resource path rather than querying each node
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
9dbbb5909a
commit
1d4981c93f
@ -23,28 +23,19 @@ async function populateInstances () {
|
|||||||
goToPage("login.html");
|
goToPage("login.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
let nodes = await request("/nodes", "GET", null);
|
let resources = await request("/cluster/resources", "GET", null);
|
||||||
let instances = [];
|
|
||||||
|
|
||||||
let instanceContainer = document.getElementById("instance-container")
|
let instanceContainer = document.getElementById("instance-container")
|
||||||
|
|
||||||
for (let i = 0; i < nodes.data.length; i++) {
|
instances = [];
|
||||||
let nodeName = nodes.data[i].node;
|
|
||||||
let nodeStatus = nodes.data[i].status;
|
|
||||||
|
|
||||||
let qemu = await request(`/nodes/${nodeName}/qemu`, "GET");
|
resources.data.forEach((element) => {
|
||||||
qemu.data.forEach((item) => {
|
if (element.type === "lxc" || element.type === "qemu") {
|
||||||
item.node = {name: nodeName, status: nodeStatus};
|
let nodeName = element.node;
|
||||||
item.maxswap = 0;
|
let nodeStatus = resources.find(iem => item.node === nodeName).status;
|
||||||
item.type = "qemu";
|
element.node = {name: nodeName, status: nodeStatus};
|
||||||
});
|
|
||||||
let lxc = await request(`/nodes/${nodeName}/lxc`, "GET");
|
|
||||||
lxc.data.forEach((item) => {
|
|
||||||
item.node = {name: nodeName, status: nodeStatus};
|
|
||||||
item.type = "lxc";
|
|
||||||
});
|
|
||||||
instances = instances.concat(qemu.data, lxc.data);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
instances.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
|
instances.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user