$this->jetonKeystone(), 'OpenStack-API-Version' => 'compute 2.99', ]) ->post(config('openstack.nova_url')."/servers/{$instanceId}/remote-consoles", [ 'remote_console' => ['protocol' => 'serial', 'type' => 'serial'], ]); if ($reponse->failed()) { throw new RuntimeException("Nova a refusé la demande de console série pour {$instanceId} : ".$reponse->body()); } return $reponse->json('remote_console.url'); } /** * Jeton Keystone mis en cache (un jeton v3 dure 1h côté Keystone, on le * garde un peu moins longtemps par prudence). */ private function jetonKeystone(): string { return Cache::remember('openstack.jeton_keystone', now()->addMinutes(50), function () { $reponse = Http::post(config('openstack.auth_url').'/v3/auth/tokens', [ 'auth' => [ 'identity' => [ 'methods' => ['application_credential'], 'application_credential' => [ 'id' => config('openstack.application_credential_id'), 'secret' => config('openstack.application_credential_secret'), ], ], ], ]); if ($reponse->failed()) { throw new RuntimeException('Authentification OpenStack refusée : '.$reponse->body()); } return $reponse->header('X-Subject-Token'); }); } }