From 14fa48bd86591e655402510962cf732f6ec2835e Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 17 Feb 2023 22:17:00 +0000 Subject: [PATCH] add changing cpu and memory values Signed-off-by: Arthur Lu --- index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.js b/index.js index 1149ebd..456b8a9 100644 --- a/index.js +++ b/index.js @@ -107,6 +107,22 @@ app.post("/api/disk/delete", async (req, res) => { } }); +app.post("/api/resources", async (req, res) => { + let vmpath = `/nodes/${req.body.node}/${req.body.type}/${req.body.vmid}`; + + let auth = await checkAuth(req.cookies, vmpath); + if (auth) { + let method = req.body.type === "qemu" ? "POST" : "PUT"; + action = JSON.stringify({cores: req.body.cores, memory: req.body.memory}); + let result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken); + result = await handleResponse(req.body.node, result); + res.send({auth: auth, status: result.status, data: result.data.data}); + } + else { + res.send({auth: auth}); + } +}); + async function checkAuth (cookies, vmpath = null) { if (vmpath) { let result = await requestPVE(`/${vmpath}/config`, "GET", cookies);