implement POST /api/disk/move

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-02-02 19:34:51 +00:00
parent d479879d2c
commit 6460f6fd51

View File

@ -61,6 +61,22 @@ app.post("/api/disk/resize", (req, res) => {
}, vmpath); }, vmpath);
}); });
app.post("/api/disk/move", (req, res) => {
let vmpath = `nodes/${req.body.node}/${req.body.type}/${req.body.vmid}`;
let route = req.body.type === "qemu" ? "move_disk" : "move_volume";
checkAuth(req.cookies, (result) => {
if (result) {
let method = "POST";
requestPVE(`/${vmpath}/${route}`, method, req.cookies, (result) => {
res.send(result);
}, body = req.body.action, token = pveAPIToken);
}
else {
res.send({auth: result});
}
}, vmpath);
});
function checkAuth (cookies, callback, vmpath = null) { function checkAuth (cookies, callback, vmpath = null) {
if (vmpath) { if (vmpath) {
requestPVE(`/${vmpath}/config`, "GET", cookies, (result) => { requestPVE(`/${vmpath}/config`, "GET", cookies, (result) => {