@@ 223-229 (lines=7) @@ | ||
220 | $totals = Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node_id', $node->id)->first(); |
|
221 | ||
222 | // Check memory limits |
|
223 | if (is_numeric($node->memory_overallocate)) { |
|
224 | $newMemory = $totals->memory + $data['memory']; |
|
225 | $memoryLimit = ($node->memory * (1 + ($node->memory_overallocate / 100))); |
|
226 | if ($newMemory > $memoryLimit) { |
|
227 | throw new DisplayException('The amount of memory allocated to this server would put the node over its allocation limits. This node is allowed ' . ($node->memory_overallocate + 100) . '% of its assigned ' . $node->memory . 'Mb of memory (' . $memoryLimit . 'Mb) of which ' . (($totals->memory / $node->memory) * 100) . '% (' . $totals->memory . 'Mb) is in use already. By allocating this server the node would be at ' . (($newMemory / $node->memory) * 100) . '% (' . $newMemory . 'Mb) usage.'); |
|
228 | } |
|
229 | } |
|
230 | ||
231 | // Check Disk Limits |
|
232 | if (is_numeric($node->disk_overallocate)) { |
|
@@ 232-238 (lines=7) @@ | ||
229 | } |
|
230 | ||
231 | // Check Disk Limits |
|
232 | if (is_numeric($node->disk_overallocate)) { |
|
233 | $newDisk = $totals->disk + $data['disk']; |
|
234 | $diskLimit = ($node->disk * (1 + ($node->disk_overallocate / 100))); |
|
235 | if ($newDisk > $diskLimit) { |
|
236 | throw new DisplayException('The amount of disk allocated to this server would put the node over its allocation limits. This node is allowed ' . ($node->disk_overallocate + 100) . '% of its assigned ' . $node->disk . 'Mb of disk (' . $diskLimit . 'Mb) of which ' . (($totals->disk / $node->disk) * 100) . '% (' . $totals->disk . 'Mb) is in use already. By allocating this server the node would be at ' . (($newDisk / $node->disk) * 100) . '% (' . $newDisk . 'Mb) usage.'); |
|
237 | } |
|
238 | } |
|
239 | } |
|
240 | } |
|
241 |