fix bug with unconverted resource types
This commit is contained in:
@@ -294,11 +294,11 @@ router.post(`${basePath}/create`, async (req, res) => {
|
||||
// setup request
|
||||
const request = {
|
||||
cores: Number(params.cores),
|
||||
memory: Number(params.memory)
|
||||
memory: Number(params.memory) * 1024 ** 2
|
||||
};
|
||||
if (params.type === "lxc") {
|
||||
request.swap = params.swap;
|
||||
request[params.rootfslocation] = params.rootfssize;
|
||||
request.swap = Number(params.swap) * 1024 ** 2;
|
||||
request[params.rootfslocation] = params.rootfssize * 1024 ** 3;
|
||||
}
|
||||
for (const key of Object.keys(user.templates.instances[params.type])) {
|
||||
const item = user.templates.instances[params.type][key];
|
||||
|
@@ -248,8 +248,8 @@ export async function approveResources (req, user, request, node) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if either the requested or avail resource is NaN, block
|
||||
else if (isNaN(resourceData.avail) || isNaN(request[key])) {
|
||||
// if either the requested or avail resource is not strictly a number, block
|
||||
else if (typeof (resourceData.avail) !== "number" || typeof (request[key]) !== "number") {
|
||||
approved = false;
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user