check storage on disk create only when disk is not ide
This commit is contained in:
parent
4fa5fb158f
commit
8a8a4c0df6
@ -409,6 +409,7 @@ app.delete("/api/instance/disk/delete", async (req, res) => {
|
|||||||
* - disk: String - disk id (sata0, ide0)
|
* - disk: String - disk id (sata0, ide0)
|
||||||
* - storage: String - storage to hold disk
|
* - storage: String - storage to hold disk
|
||||||
* - size: Number - size of disk in GiB
|
* - size: Number - size of disk in GiB
|
||||||
|
* - iso: String - file name to mount as cdrom
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: PVE Task Object
|
* - 200: PVE Task Object
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
@ -431,14 +432,14 @@ app.post("/api/instance/disk/create", async (req, res) => {
|
|||||||
// setup request
|
// setup request
|
||||||
let request = {};
|
let request = {};
|
||||||
if (!req.body.disk.includes("ide")) {
|
if (!req.body.disk.includes("ide")) {
|
||||||
request[req.body.storage] = Number(req.body.size * 1024 ** 3); // setup request object
|
// setup request
|
||||||
|
request[req.body.storage] = Number(req.body.size * 1024 ** 3);
|
||||||
// check request approval
|
// check request approval
|
||||||
if (!await approveResources(req, req.cookies.username, request)) {
|
if (!await approveResources(req, req.cookies.username, request)) {
|
||||||
res.status(500).send({ request: request, error: `Storage ${req.body.storage} could not fulfill request of size ${req.body.size}G.` });
|
res.status(500).send({ request: request, error: `Storage ${req.body.storage} could not fulfill request of size ${req.body.size}G.` });
|
||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// target disk must be allowed according to storage options
|
// target disk must be allowed according to storage options
|
||||||
let resourceConfig = db.getResourceConfig();
|
let resourceConfig = db.getResourceConfig();
|
||||||
if (!resourceConfig[req.body.storage].disks.some(diskPrefix => req.body.disk.startsWith(diskPrefix))) {
|
if (!resourceConfig[req.body.storage].disks.some(diskPrefix => req.body.disk.startsWith(diskPrefix))) {
|
||||||
@ -446,6 +447,7 @@ app.post("/api/instance/disk/create", async (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// setup action
|
// setup action
|
||||||
let action = {};
|
let action = {};
|
||||||
if (req.body.disk.includes("ide") && req.body.iso) {
|
if (req.body.disk.includes("ide") && req.body.iso) {
|
||||||
|
Loading…
Reference in New Issue
Block a user