mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00

* Not found property rule * Make these “better” * Day 1 * Day 2 * Day 3 * Dat 4 * Remove disabled check * Day 4 continued * Run pint * Final changes hopefully * Pint fixes * Fix again * Reset these * Update app/Filament/Admin/Pages/Health.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> * Update app/Traits/CheckMigrationsTrait.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> --------- Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\Daemon;
|
|
|
|
use App\Models\Node;
|
|
use Illuminate\Http\Client\ConnectionException;
|
|
use Illuminate\Http\Client\Response;
|
|
|
|
class DaemonConfigurationRepository extends DaemonRepository
|
|
{
|
|
/**
|
|
* Returns system information from the daemon instance.
|
|
*
|
|
* @return array<mixed>
|
|
*
|
|
* @throws ConnectionException
|
|
*/
|
|
public function getSystemInformation(): array
|
|
{
|
|
return $this->getHttpClient()
|
|
->connectTimeout(3)
|
|
->get('/api/system')
|
|
->throwIf(function ($result) {
|
|
$header = $result->header('User-Agent');
|
|
if (
|
|
filled($header) &&
|
|
preg_match('/^Pelican Wings\/v(?:\d+\.\d+\.\d+|develop) \(id:(\w*)\)$/', $header, $matches) &&
|
|
array_get($matches, 1, '') !== $this->node->daemon_token_id
|
|
) {
|
|
throw new ConnectionException($result->effectiveUri()->__toString() . ' does not match node token_id !');
|
|
}
|
|
if (!$result->collect()->has(['architecture', 'cpu_count', 'kernel_version', 'os', 'version'])) {
|
|
throw new ConnectionException($result->effectiveUri()->__toString() . ' is not Pelican Wings !');
|
|
}
|
|
|
|
return true;
|
|
})->json();
|
|
}
|
|
|
|
/**
|
|
* Updates the configuration information for a daemon. Updates the information for
|
|
* this instance using a passed-in model. This allows us to change plenty of information
|
|
* in the model, and still use the old, pre-update model to actually make the HTTP request.
|
|
*
|
|
* @throws ConnectionException
|
|
*/
|
|
public function update(Node $node): Response
|
|
{
|
|
return $this->getHttpClient()->post('/api/update', $node->getConfiguration());
|
|
}
|
|
}
|