ajoute le proxy console Go et le relais WebSocket vers nova-serialproxy
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
30e14b1c54
commit
8742bde807
30 changed files with 1103 additions and 6 deletions
47
portail/app/Services/OpenStack/JetonConsole.php
Normal file
47
portail/app/Services/OpenStack/JetonConsole.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\OpenStack;
|
||||
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Range l'adresse de la console série dans Redis sous un jeton aléatoire,
|
||||
* pour 5 minutes (étape 9). Le navigateur ne reçoit que ce jeton, jamais
|
||||
* l'URL ni le jeton Nova sous-jacent. Format lu par proxy-console/main.go :
|
||||
* ne pas changer les noms de champs sans mettre à jour les deux côtés.
|
||||
*/
|
||||
class JetonConsole
|
||||
{
|
||||
private const DUREE_MINUTES = 5;
|
||||
|
||||
public function __construct(private readonly NovaClient $nova) {}
|
||||
|
||||
public function pourEcriture(string $instanceId): string
|
||||
{
|
||||
return $this->creer($instanceId, 'ecriture');
|
||||
}
|
||||
|
||||
public function pourLecture(string $instanceId): string
|
||||
{
|
||||
return $this->creer($instanceId, 'lecture');
|
||||
}
|
||||
|
||||
private function creer(string $instanceId, string $role): string
|
||||
{
|
||||
$jeton = Str::random(40);
|
||||
$url = $this->nova->consoleSerielle($instanceId);
|
||||
|
||||
Redis::setex(
|
||||
"console:{$jeton}",
|
||||
self::DUREE_MINUTES * 60,
|
||||
json_encode([
|
||||
'url' => $url,
|
||||
'instance_id' => $instanceId,
|
||||
'role' => $role,
|
||||
]),
|
||||
);
|
||||
|
||||
return $jeton;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue