check resource approval only if pci device differs
This commit is contained in:
parent
8307e07dae
commit
5014e1d10c
15
src/main.js
15
src/main.js
@ -694,11 +694,19 @@ app.post("/api/instance/pci/modify", async (req, res) => {
|
|||||||
if (!auth) { return; }
|
if (!auth) { return; }
|
||||||
// force all functions
|
// force all functions
|
||||||
req.body.device = req.body.device.split(".")[0];
|
req.body.device = req.body.device.split(".")[0];
|
||||||
|
// get instance config to check if device has not changed
|
||||||
|
let config = (await requestPVE(`/nodes/${req.body.node}/${req.body.type}/${req.body.vmid}/config`, "GET", req.body.cookies, null, pveAPIToken)).data.data;
|
||||||
|
let currentDeviceData = await getDeviceInfo(req.body.node, req.body.type, req.body.vmid, config[`hostpci${req.body.hostpci}`].split(",")[0]);
|
||||||
|
if (!currentDeviceData) {
|
||||||
|
res.status(500).send({ error: `No device in hostpci${req.body.hostpci}.` });
|
||||||
|
res.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// only check user and node availability if base id is different
|
||||||
|
if (currentDeviceData.id.split(".")[0] !== req.body.device) {
|
||||||
// setup request
|
// setup request
|
||||||
let deviceData = await getDeviceInfo(req.body.node, req.body.type, req.body.vmid, req.body.device);
|
let deviceData = await getDeviceInfo(req.body.node, req.body.type, req.body.vmid, req.body.device);
|
||||||
let request = {
|
let request = { pci: deviceData.device_name };
|
||||||
pci: deviceData.device_name
|
|
||||||
};
|
|
||||||
// check resource approval
|
// check resource approval
|
||||||
if (!await approveResources(req, req.cookies.username, request)) {
|
if (!await approveResources(req, req.cookies.username, request)) {
|
||||||
res.status(500).send({ request: request, error: `Could not fulfil request for ${deviceData.device_name}.` });
|
res.status(500).send({ request: request, error: `Could not fulfil request for ${deviceData.device_name}.` });
|
||||||
@ -712,6 +720,7 @@ app.post("/api/instance/pci/modify", async (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// setup action
|
// setup action
|
||||||
let action = {};
|
let action = {};
|
||||||
action[`hostpci${req.body.hostpci}`] = `${req.body.device},pcie=${req.body.pcie}`;
|
action[`hostpci${req.body.hostpci}`] = `${req.body.device},pcie=${req.body.pcie}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user