simplify requestPVE args
This commit is contained in:
+10
-10
@@ -37,7 +37,7 @@ router.post("/:disk/detach", async (req, res) => {
|
||||
return;
|
||||
}
|
||||
// get current config
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", req.cookies, null, null)).data.data;
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", { cookies: req.cookies })).data.data;
|
||||
// disk must exist
|
||||
if (!config[params.disk]) {
|
||||
res.status(500).send({ error: `Disk ${params.disk} does not exist.` });
|
||||
@@ -52,7 +52,7 @@ router.post("/:disk/detach", async (req, res) => {
|
||||
}
|
||||
const action = JSON.stringify({ delete: params.disk });
|
||||
const method = params.type === "qemu" ? "POST" : "PUT";
|
||||
const result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/config`, method, { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ router.post("/:disk/attach", async (req, res) => {
|
||||
return;
|
||||
}
|
||||
// get current config
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", req.cookies, null, null)).data.data;
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", { cookies: req.cookies })).data.data;
|
||||
// disk must exist
|
||||
if (!config[`unused${params.source}`]) {
|
||||
res.status(403).send({ error: `Requested disk unused${params.source} does not exist.` });
|
||||
@@ -107,7 +107,7 @@ router.post("/:disk/attach", async (req, res) => {
|
||||
action = JSON.stringify(action);
|
||||
const method = params.type === "qemu" ? "POST" : "PUT";
|
||||
// commit action
|
||||
const result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/config`, method, { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
@@ -160,7 +160,7 @@ router.post("/:disk/resize", async (req, res) => {
|
||||
}
|
||||
// action approved, commit to action
|
||||
const action = JSON.stringify({ disk: params.disk, size: `+${params.size}G` });
|
||||
const result = await requestPVE(`${vmpath}/resize`, "PUT", req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/resize`, "PUT", { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
@@ -227,7 +227,7 @@ router.post("/:disk/move", async (req, res) => {
|
||||
action = JSON.stringify(action);
|
||||
const route = params.type === "qemu" ? "move_disk" : "move_volume";
|
||||
// commit action
|
||||
const result = await requestPVE(`${vmpath}/${route}`, "POST", req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/${route}`, "POST", { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
@@ -259,7 +259,7 @@ router.delete("/:disk/delete", async (req, res) => {
|
||||
return;
|
||||
}
|
||||
// get current config
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", req.cookies, null, null)).data.data;
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", { cookies: req.cookies })).data.data;
|
||||
// disk must exist
|
||||
if (!config[params.disk]) {
|
||||
res.status(403).send({ error: `Requested disk unused${params.source} does not exist.` });
|
||||
@@ -276,7 +276,7 @@ router.delete("/:disk/delete", async (req, res) => {
|
||||
const action = JSON.stringify({ delete: params.disk });
|
||||
const method = params.type === "qemu" ? "POST" : "PUT";
|
||||
// commit action
|
||||
const result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/config`, method, { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
@@ -314,7 +314,7 @@ router.post("/:disk/create", async (req, res) => {
|
||||
return;
|
||||
}
|
||||
// get current config
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", req.cookies, null, null)).data.data;
|
||||
const config = (await requestPVE(`${vmpath}/config`, "GET", { cookies: req.cookies })).data.data;
|
||||
// disk must not exist
|
||||
if (config[params.disk]) {
|
||||
res.status(403).send({ error: `Requested disk ${params.disk} already exists.` });
|
||||
@@ -354,6 +354,6 @@ router.post("/:disk/create", async (req, res) => {
|
||||
action = JSON.stringify(action);
|
||||
const method = params.type === "qemu" ? "POST" : "PUT";
|
||||
// commit action
|
||||
const result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken);
|
||||
const result = await requestPVE(`${vmpath}/config`, method, { token: pveAPIToken }, action);
|
||||
await handleResponse(params.node, result, res);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user