|
@@ 221-227 (lines=7) @@
|
| 218 |
|
$totals = Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first(); |
| 219 |
|
|
| 220 |
|
// Check memory limits |
| 221 |
|
if (is_numeric($node->memory_overallocate)) { |
| 222 |
|
$newMemory = $totals->memory + $data['memory']; |
| 223 |
|
$memoryLimit = ($node->memory * (1 + ($node->memory_overallocate / 100))); |
| 224 |
|
if ($newMemory > $memoryLimit) { |
| 225 |
|
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.'); |
| 226 |
|
} |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
// Check Disk Limits |
| 230 |
|
if (is_numeric($node->disk_overallocate)) { |
|
@@ 230-236 (lines=7) @@
|
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
// Check Disk Limits |
| 230 |
|
if (is_numeric($node->disk_overallocate)) { |
| 231 |
|
$newDisk = $totals->disk + $data['disk']; |
| 232 |
|
$diskLimit = ($node->disk * (1 + ($node->disk_overallocate / 100))); |
| 233 |
|
if ($newDisk > $diskLimit) { |
| 234 |
|
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.'); |
| 235 |
|
} |
| 236 |
|
} |
| 237 |
|
} |
| 238 |
|
} |
| 239 |
|
|