mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-30 12:34:45 +02:00
Delete allocation exceptions
This commit is contained in:
parent
a2108c3d91
commit
4eeefab6c6
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\PanelException;
|
|
||||||
|
|
||||||
class AllocationDoesNotBelongToServerException extends PanelException
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class AutoAllocationNotEnabledException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* AutoAllocationNotEnabledException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct(
|
|
||||||
'Server auto-allocation is not enabled for this instance.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class CidrOutOfRangeException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* CidrOutOfRangeException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct(trans('exceptions.ports.cidr_out_of_range'));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class InvalidPortMappingException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* InvalidPortMappingException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(mixed $port)
|
|
||||||
{
|
|
||||||
parent::__construct(trans('exceptions.ports.invalid_mapping', ['port' => $port]));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class NoAutoAllocationSpaceAvailableException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* NoAutoAllocationSpaceAvailableException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct(
|
|
||||||
'Cannot assign additional allocation: no more space available on node.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class PortOutOfRangeException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* PortOutOfRangeException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct(trans('exceptions.ports.port_out_of_range'));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Allocation;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class TooManyPortsInRangeException extends DisplayException
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* TooManyPortsInRangeException constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct(trans('exceptions.ports.too_many_ports'));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Exceptions\Service\Deployment;
|
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
|
||||||
|
|
||||||
class NoViableAllocationException extends DisplayException
|
|
||||||
{
|
|
||||||
}
|
|
@ -47,7 +47,6 @@ class CreateServerController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @throws \App\Exceptions\DisplayException
|
* @throws \App\Exceptions\DisplayException
|
||||||
* @throws \App\Exceptions\Service\Deployment\NoViableAllocationException
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function store(ServerFormRequest $request): RedirectResponse
|
public function store(ServerFormRequest $request): RedirectResponse
|
||||||
|
@ -47,12 +47,8 @@ class ServerViewController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function build(Server $server): View
|
public function build(Server $server): View
|
||||||
{
|
{
|
||||||
$allocations = $server->node->allocations->toBase();
|
|
||||||
|
|
||||||
return view('admin.servers.view.build', [
|
return view('admin.servers.view.build', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
|
|
||||||
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ class ServerController extends ApplicationApiController
|
|||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @throws \App\Exceptions\DisplayException
|
* @throws \App\Exceptions\DisplayException
|
||||||
* @throws \App\Exceptions\Model\DataValidationException
|
* @throws \App\Exceptions\Model\DataValidationException
|
||||||
* @throws \App\Exceptions\Service\Deployment\NoViableAllocationException
|
|
||||||
*/
|
*/
|
||||||
public function store(StoreServerRequest $request): JsonResponse
|
public function store(StoreServerRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,6 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
* @property \Carbon\Carbon $updated_at
|
* @property \Carbon\Carbon $updated_at
|
||||||
* @property \App\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts
|
* @property \App\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts
|
||||||
* @property \App\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
|
* @property \App\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
|
||||||
* @property \App\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations
|
|
||||||
*/
|
*/
|
||||||
class Node extends Model
|
class Node extends Model
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
|||||||
* @property int $cpu
|
* @property int $cpu
|
||||||
* @property string|null $threads
|
* @property string|null $threads
|
||||||
* @property bool $oom_killer
|
* @property bool $oom_killer
|
||||||
* @property int $allocation_id
|
|
||||||
* @property int $egg_id
|
* @property int $egg_id
|
||||||
* @property string $startup
|
* @property string $startup
|
||||||
* @property string $image
|
* @property string $image
|
||||||
@ -53,7 +52,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
|||||||
* @property \Illuminate\Support\Carbon|null $installed_at
|
* @property \Illuminate\Support\Carbon|null $installed_at
|
||||||
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\ActivityLog[] $activity
|
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\ActivityLog[] $activity
|
||||||
* @property int|null $activity_count
|
* @property int|null $activity_count
|
||||||
* @property \App\Models\Allocation|null $allocation
|
|
||||||
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Allocation[] $allocations
|
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Allocation[] $allocations
|
||||||
* @property int|null $allocations_count
|
* @property int|null $allocations_count
|
||||||
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Backup[] $backups
|
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Backup[] $backups
|
||||||
@ -79,7 +77,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
|||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Server newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server query()
|
* @method static \Illuminate\Database\Eloquent\Builder|Server query()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationId($value)
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationLimit($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationLimit($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereBackupLimit($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|Server whereBackupLimit($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereCpu($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|Server whereCpu($value)
|
||||||
@ -200,7 +197,7 @@ class Server extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the format for server allocations when communicating with the Daemon.
|
* Returns the format for server's ports when communicating with the Daemon.
|
||||||
*/
|
*/
|
||||||
public function getPortMappings(): array
|
public function getPortMappings(): array
|
||||||
{
|
{
|
||||||
|
@ -6,8 +6,6 @@ use App\Models\Objects\Endpoint;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Exceptions\Service\Allocation\AutoAllocationNotEnabledException;
|
|
||||||
use App\Exceptions\Service\Allocation\NoAutoAllocationSpaceAvailableException;
|
|
||||||
|
|
||||||
class FindAssignableAllocationService
|
class FindAssignableAllocationService
|
||||||
{
|
{
|
||||||
@ -15,15 +13,9 @@ class FindAssignableAllocationService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AutoAllocationNotEnabledException
|
|
||||||
* @throws NoAutoAllocationSpaceAvailableException
|
|
||||||
*/
|
|
||||||
public function handle(Server $server): int
|
public function handle(Server $server): int
|
||||||
{
|
{
|
||||||
if (!config('panel.client_features.allocations.enabled')) {
|
abort_unless(config('panel.client_features.allocations.enabled'), 403, 'Auto Allocation is not enabled');
|
||||||
throw new AutoAllocationNotEnabledException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->createNewAllocation($server);
|
return $this->createNewAllocation($server);
|
||||||
}
|
}
|
||||||
@ -32,18 +24,12 @@ class FindAssignableAllocationService
|
|||||||
* Create a new allocation on the server's node with a random port from the defined range
|
* Create a new allocation on the server's node with a random port from the defined range
|
||||||
* in the settings. If there are no matches in that range, or something is wrong with the
|
* in the settings. If there are no matches in that range, or something is wrong with the
|
||||||
* range information provided an exception will be raised.
|
* range information provided an exception will be raised.
|
||||||
*
|
|
||||||
* @throws NoAutoAllocationSpaceAvailableException
|
|
||||||
*/
|
*/
|
||||||
protected function createNewAllocation(Server $server): int
|
protected function createNewAllocation(Server $server): int
|
||||||
{
|
{
|
||||||
$start = config('panel.client_features.allocations.range_start');
|
$start = config('panel.client_features.allocations.range_start');
|
||||||
$end = config('panel.client_features.allocations.range_end');
|
$end = config('panel.client_features.allocations.range_end');
|
||||||
|
|
||||||
if (!$start || !$end) {
|
|
||||||
throw new NoAutoAllocationSpaceAvailableException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert::integerish($start);
|
Assert::integerish($start);
|
||||||
Assert::integerish($end);
|
Assert::integerish($end);
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ use Illuminate\Support\Collection;
|
|||||||
class FindViableNodesService
|
class FindViableNodesService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns a collection of nodes that meet the provided requirements and can then
|
* Returns a collection of nodes that meet the provided requirements
|
||||||
* be passed to the AllocationSelectionService to return a single allocation.
|
|
||||||
*
|
*
|
||||||
* This functionality is used for automatic deployments of servers and will
|
* This functionality is used for automatic deployments of servers and will
|
||||||
* attempt to find all nodes in the defined locations that meet the memory, disk
|
* attempt to find all nodes in the defined locations that meet the memory, disk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user