Skip to content

Commit 166812b

Browse files
committed
Merge branch 'release/v0.7.4'
2 parents 833b214 + 95c1fe4 commit 166812b

File tree

94 files changed

+2246
-754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2246
-754
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v0.7.4 (Derelict Dermodactylus)
7+
### Fixed
8+
* Fixes a bug when reinstalling a server that would not mark the server as installing, resulting in some UI issues.
9+
* Handle 404 errors from missing models in the application API bindings correctly.
10+
* Fix validation error returned when no environment variables are passed, even if there are no variables required.
11+
* Fix improper permissions on `PATCH /api/servers/<id>/startup` endpoint which was preventing enditing any start variables.
12+
* Should fix migration issues from 0.6 when there are more than API key in the database.
13+
14+
### Changed
15+
* Changes order that validation of resource existence occurs in API requests to not try and use a non-existent model when validating data.
16+
17+
### Added
18+
* Adds back client API for sending commands or power toggles to a server though the Panel API: `/api/client/servers/<identifier>`
19+
* Added proper transformer for Packs and re-enabled missing includes on server.
20+
* Added support for using Filesystem as a caching driver, although not recommended.
21+
* Added support for user management of server databases.
22+
* **Added bulk power management CLI interface to send start, stop, kill, restart actions to servers across configurable nodes.**
23+
624
## v0.7.3 (Derelict Dermodactylus)
725
### Fixed
826
* Fixes server creation API endpoint not passing the provided `external_id` to the creation service.

app/Console/Commands/Environment/AppSettingsCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AppSettingsCommand extends Command
2222
const ALLOWED_CACHE_DRIVERS = [
2323
'redis' => 'Redis (recommended)',
2424
'memcached' => 'Memcached',
25+
'file' => 'Filesystem',
2526
];
2627

2728
const ALLOWED_SESSION_DRIVERS = [
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
namespace Pterodactyl\Console\Commands\Server;
4+
5+
use Illuminate\Console\Command;
6+
use GuzzleHttp\Exception\RequestException;
7+
use Illuminate\Validation\ValidationException;
8+
use Illuminate\Validation\Factory as ValidatorFactory;
9+
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
10+
use Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface;
11+
12+
class BulkPowerActionCommand extends Command
13+
{
14+
/**
15+
* @var \Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface
16+
*/
17+
private $powerRepository;
18+
19+
/**
20+
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
21+
*/
22+
private $repository;
23+
24+
/**
25+
* @var \Illuminate\Validation\Factory
26+
*/
27+
private $validator;
28+
29+
/**
30+
* @var string
31+
*/
32+
protected $signature = 'p:server:bulk-power
33+
{action : The action to perform (start, stop, restart, kill)}
34+
{--servers= : A comma seperated list of servers.}
35+
{--nodes= : A comma seperated list of nodes.}';
36+
37+
/**
38+
* @var string
39+
*/
40+
protected $description = 'Perform bulk power management on large groupings of servers or nodes at once.';
41+
42+
/**
43+
* BulkPowerActionCommand constructor.
44+
*
45+
* @param \Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface $powerRepository
46+
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
47+
* @param \Illuminate\Validation\Factory $validator
48+
*/
49+
public function __construct(
50+
PowerRepositoryInterface $powerRepository,
51+
ServerRepositoryInterface $repository,
52+
ValidatorFactory $validator
53+
) {
54+
parent::__construct();
55+
56+
$this->powerRepository = $powerRepository;
57+
$this->repository = $repository;
58+
$this->validator = $validator;
59+
}
60+
61+
/**
62+
* Handle the bulk power request.
63+
*
64+
* @throws \Illuminate\Validation\ValidationException
65+
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
66+
*/
67+
public function handle()
68+
{
69+
$action = $this->argument('action');
70+
$nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes'));
71+
$servers = empty($this->option('servers')) ? [] : explode(',', $this->option('servers'));
72+
73+
$validator = $this->validator->make([
74+
'action' => $action,
75+
'nodes' => $nodes,
76+
'servers' => $servers,
77+
], [
78+
'action' => 'string|in:start,stop,kill,restart',
79+
'nodes' => 'array',
80+
'nodes.*' => 'integer|min:1',
81+
'servers' => 'array',
82+
'servers.*' => 'integer|min:1',
83+
]);
84+
85+
if ($validator->fails()) {
86+
foreach ($validator->getMessageBag()->all() as $message) {
87+
$this->output->error($message);
88+
}
89+
90+
throw new ValidationException($validator);
91+
}
92+
93+
$count = $this->repository->getServersForPowerActionCount($servers, $nodes);
94+
if (! $this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count]))) {
95+
return;
96+
}
97+
98+
$bar = $this->output->createProgressBar($count);
99+
$servers = $this->repository->getServersForPowerAction($servers, $nodes);
100+
101+
foreach ($servers as $server) {
102+
$bar->clear();
103+
104+
try {
105+
$this->powerRepository->setServer($server)->sendSignal($action);
106+
} catch (RequestException $exception) {
107+
$this->output->error(trans('command/messages.server.power.action_failed', [
108+
'name' => $server->name,
109+
'id' => $server->id,
110+
'node' => $server->node->name,
111+
'message' => $exception->getMessage(),
112+
]));
113+
}
114+
115+
$bar->advance();
116+
$bar->display();
117+
}
118+
119+
$this->line('');
120+
}
121+
}

app/Contracts/Repository/ServerRepositoryInterface.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,23 @@ public function filterUserAccessServers(User $user, int $level, bool $paginate =
117117
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
118118
*/
119119
public function getByUuid(string $uuid): Server;
120+
121+
/**
122+
* Return all of the servers that should have a power action performed aganist them.
123+
*
124+
* @param int[] $servers
125+
* @param int[] $nodes
126+
* @param bool $returnCount
127+
* @return int|\Generator
128+
*/
129+
public function getServersForPowerAction(array $servers = [], array $nodes = [], bool $returnCount = false);
130+
131+
/**
132+
* Return the total number of servers that will be affected by the query.
133+
*
134+
* @param int[] $servers
135+
* @param int[] $nodes
136+
* @return int
137+
*/
138+
public function getServersForPowerActionCount(array $servers = [], array $nodes = []): int;
120139
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions\Service\Database;
4+
5+
use Pterodactyl\Exceptions\PterodactylException;
6+
7+
class DatabaseClientFeatureNotEnabledException extends PterodactylException
8+
{
9+
public function __construct()
10+
{
11+
parent::__construct('Client database creation is not enabled in this Panel.');
12+
}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions\Service\Database;
4+
5+
use Pterodactyl\Exceptions\DisplayException;
6+
7+
class NoSuitableDatabaseHostException extends DisplayException
8+
{
9+
/**
10+
* NoSuitableDatabaseHostException constructor.
11+
*/
12+
public function __construct()
13+
{
14+
parent::__construct('No database host was found that meets the requirements for this server.');
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions\Service\Database;
4+
5+
use Pterodactyl\Exceptions\DisplayException;
6+
7+
class TooManyDatabasesException extends DisplayException
8+
{
9+
public function __construct()
10+
{
11+
parent::__construct('Operation aborted: creating a new database would put this server over the defined limit.');
12+
}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions\Transformer;
4+
5+
use Pterodactyl\Exceptions\PterodactylException;
6+
7+
class InvalidTransformerLevelException extends PterodactylException
8+
{
9+
}

app/Http/Controllers/Admin/NodesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function delete($node)
366366
public function setToken(Node $node)
367367
{
368368
$token = bin2hex(random_bytes(16));
369-
$this->cache->tags(['Node:Configuration'])->put($token, $node->id, 5);
369+
$this->cache->put('Node:Configuration:' . $token, $node->id, 5);
370370

371371
return response()->json(['token' => $token]);
372372
}

app/Http/Controllers/Admin/ServersController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,17 @@ public function manageSuspension(Request $request, Server $server)
498498
* @param \Illuminate\Http\Request $request
499499
* @param \Pterodactyl\Models\Server $server
500500
* @return \Illuminate\Http\RedirectResponse
501+
*
501502
* @throws \Pterodactyl\Exceptions\DisplayException
502503
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
503-
* @internal param int $id
504+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
504505
*/
505506
public function updateBuild(Request $request, Server $server)
506507
{
507508
$this->buildModificationService->handle($server, $request->only([
508509
'allocation_id', 'add_allocations', 'remove_allocations',
509510
'memory', 'swap', 'io', 'cpu', 'disk',
511+
'database_limit', 'allocation_limit',
510512
]));
511513
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
512514

0 commit comments

Comments
 (0)