From ab235fe5813b3b57cc08cc7e2f6acd78dbcba6ba Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 23 Feb 2023 20:39:33 +0000 Subject: [PATCH] add disk create endpoint Signed-off-by: Arthur Lu --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index 2c8053c..e172bf3 100644 --- a/index.js +++ b/index.js @@ -108,6 +108,21 @@ app.post("/api/disk/delete", async (req, res) => { } }); +app.post("/api/disk/create", 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"; + let result = await requestPVE(`${vmpath}/config`, method, req.cookies, req.body.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}); + } +}); + app.post("/api/resources", async (req, res) => { let vmpath = `/nodes/${req.body.node}/${req.body.type}/${req.body.vmid}`;