workaround for node pcie get devices

This commit is contained in:
2026-05-26 18:44:03 +00:00
parent 24ed6907c7
commit 4bc71e2212
+12 -7
View File
@@ -63,7 +63,10 @@ router.get(`/:node(${nodeRegexP})/pci`, async (req, res) => {
if (!auth) { if (!auth) {
return; return;
} }
const userNodes = (await global.access.getPool(userObj, req.cookies)).cluster.nodes;
/* todo this should check pool membership
pool = await global.access.getPool(instance.pool, req.cookies)
const userNodes = pool["nodes-allowed"];
if (userNodes[params.node] !== true) { // user does not have access to the node if (userNodes[params.node] !== true) { // user does not have access to the node
res.status(401).send({ auth: false, path: params.node }); res.status(401).send({ auth: false, path: params.node });
res.end(); res.end();
@@ -76,10 +79,12 @@ router.get(`/:node(${nodeRegexP})/pci`, async (req, res) => {
res.status(200).send([]); res.status(200).send([]);
res.end(); res.end();
} }
else { */
//else {
// get node avail devices // get node avail devices
const node = await global.pve.getNode(params.node); const node = await global.pve.getNode(params.node);
let availableDevices = []; const availableDevices = [];
// get each device and filter out only thise which are not reserved // get each device and filter out only thise which are not reserved
for (const device of Object.values(node.devices)) { for (const device of Object.values(node.devices)) {
if (device.reserved === false) { if (device.reserved === false) {
@@ -87,13 +92,13 @@ router.get(`/:node(${nodeRegexP})/pci`, async (req, res) => {
} }
} }
// further filter out only devices which the user has access to // further filter out only devices which the user has access to
availableDevices = availableDevices.filter(nodeAvail => userAvailPci.some((userAvail) => { //availableDevices = availableDevices.filter(nodeAvail => userAvailPci.some((userAvail) => {
return nodeAvail.device_name && nodeAvail.device_name.includes(userAvail.match) && userAvail.avail > 0; // return nodeAvail.device_name && nodeAvail.device_name.includes(userAvail.match) && userAvail.avail > 0;
})); //}));
res.status(200).send(availableDevices); res.status(200).send(availableDevices);
res.end(); res.end();
} //}
}); });
/** /**