mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 05:14:46 +02:00
Remove daemon transfer repository
This commit is contained in:
parent
41c3f1336a
commit
4ea5341e97
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\Remote\Servers;
|
namespace App\Http\Controllers\Api\Remote\Servers;
|
||||||
|
|
||||||
|
use App\Models\Server;
|
||||||
|
use App\Repositories\Daemon\DaemonRepository;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use App\Models\Allocation;
|
use App\Models\Allocation;
|
||||||
@ -10,7 +13,7 @@ use App\Models\ServerTransfer;
|
|||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Eloquent\ServerRepository;
|
use App\Repositories\Eloquent\ServerRepository;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use Lcobucci\JWT\Token\Plain;
|
||||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
|
||||||
@ -22,10 +25,29 @@ class ServerTransferController extends Controller
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private ConnectionInterface $connection,
|
private ConnectionInterface $connection,
|
||||||
private ServerRepository $repository,
|
private ServerRepository $repository,
|
||||||
private DaemonServerRepository $daemonServerRepository
|
private DaemonRepository $daemonRepository,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function notify(DaemonRepository $repository, Server $server, Plain $token): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$repository->getHttpClient()->post('/api/transfer', [
|
||||||
|
'json' => [
|
||||||
|
'server_id' => $server->uuid,
|
||||||
|
'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive",
|
||||||
|
'token' => 'Bearer ' . $token->toString(),
|
||||||
|
'server' => [
|
||||||
|
'uuid' => $server->uuid,
|
||||||
|
'start_on_completion' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (GuzzleException $exception) {
|
||||||
|
throw new DaemonConnectionException($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The daemon notifies us about a transfer failure.
|
* The daemon notifies us about a transfer failure.
|
||||||
*
|
*
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repositories\Daemon;
|
|
||||||
|
|
||||||
use App\Models\Node;
|
|
||||||
use Lcobucci\JWT\Token\Plain;
|
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
|
||||||
|
|
||||||
class DaemonTransferRepository extends DaemonRepository
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
|
|
||||||
*/
|
|
||||||
public function notify(Node $targetNode, Plain $token): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->getHttpClient()->post(sprintf('/api/servers/%s/transfer', $this->server->uuid), [
|
|
||||||
'json' => [
|
|
||||||
'server_id' => $this->server->uuid,
|
|
||||||
'url' => $targetNode->getConnectionAddress() . '/api/transfers',
|
|
||||||
'token' => 'Bearer ' . $token->toString(),
|
|
||||||
'server' => [
|
|
||||||
'uuid' => $this->server->uuid,
|
|
||||||
'start_on_completion' => false,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
} catch (GuzzleException $exception) {
|
|
||||||
throw new DaemonConnectionException($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ parameters:
|
|||||||
- app/
|
- app/
|
||||||
|
|
||||||
# Level 9 is the highest level
|
# Level 9 is the highest level
|
||||||
level: 1
|
level: 2
|
||||||
|
|
||||||
# ignoreErrors:
|
# ignoreErrors:
|
||||||
# - '#PHPDoc tag @var#'
|
# - '#PHPDoc tag @var#'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user