ajoute le stock chaud, la correction automatique et les nouveaux essais de création de stack
Stock de stacks prêtes par lab dans Redis (prise atomique en Lua, ménage par comparaison avec Heat, disjoncteur), files gérées par Horizon, séances planifiables. Correcteur Go sur l'hyperviseur : socket Unix, commandes lues dans le lab.yaml uniquement, exécution par l'agent invité QEMU. Une création de stack ratée est supprimée et réessayée deux fois, puis la session passe en échec, visible du prof. Corrige aussi trois défauts des étapes précédentes : la console se coupait à la première frappe d'un navigateur (trames texte), l'élève ne pouvait pas rejoindre une séance, la déconnexion n'avait pas de jeton CSRF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ca2f6f3b7a
commit
80b6c0722d
71 changed files with 2959 additions and 170 deletions
|
|
@ -8,34 +8,66 @@ use Symfony\Component\Yaml\Yaml;
|
|||
|
||||
/**
|
||||
* Lit le lab.yaml d'un lab (voir paillasse-contenus/README.md pour le
|
||||
* format), pour que GenerateurTemplateHeat puisse en faire une stack.
|
||||
* format) : topologie pour GenerateurTemplateHeat, vérifications pour la
|
||||
* correction.
|
||||
*/
|
||||
class DefinitionLab
|
||||
{
|
||||
public readonly string $identifiant;
|
||||
|
||||
public readonly string $titre;
|
||||
|
||||
public readonly ?string $niveau;
|
||||
|
||||
public readonly ?int $dureeMin;
|
||||
|
||||
/** @var array<int, array{nom: string, cidr: string}> */
|
||||
public readonly array $reseaux;
|
||||
|
||||
/** @var array<int, array{nom: string, image: string, flavor: string, reseaux: array<int, string>, preparation: ?string}> */
|
||||
public readonly array $machines;
|
||||
|
||||
/** @var array<int, array{id: string, titre: string, machine: string, points: int, message_echec: string, bonus: bool}> */
|
||||
public readonly array $verifications;
|
||||
|
||||
public static function depuis(string $identifiantLab): self
|
||||
{
|
||||
if (! preg_match('/^[a-z0-9][a-z0-9-]*$/', $identifiantLab)) {
|
||||
throw new RuntimeException("Identifiant de lab invalide : {$identifiantLab}");
|
||||
}
|
||||
|
||||
$chemin = config('labs.dossier')."/{$identifiantLab}/lab.yaml";
|
||||
|
||||
if (! File::exists($chemin)) {
|
||||
throw new RuntimeException("Lab introuvable : {$chemin}");
|
||||
}
|
||||
|
||||
$donnees = Yaml::parseFile($chemin);
|
||||
return new self(Yaml::parseFile($chemin));
|
||||
}
|
||||
|
||||
return new self($donnees);
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function identifiantsDisponibles(): array
|
||||
{
|
||||
return collect(File::directories(config('labs.dossier')))
|
||||
->map(fn (string $dossier) => basename($dossier))
|
||||
->filter(fn (string $id) => File::exists(config('labs.dossier')."/{$id}/lab.yaml"))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
public function nombreMachines(): int
|
||||
{
|
||||
return count($this->machines);
|
||||
}
|
||||
|
||||
private function __construct(array $donnees)
|
||||
{
|
||||
$this->identifiant = $donnees['id'];
|
||||
$this->titre = $donnees['titre'];
|
||||
$this->niveau = $donnees['niveau'] ?? null;
|
||||
$this->dureeMin = $donnees['duree_min'] ?? null;
|
||||
$this->reseaux = $donnees['reseaux'];
|
||||
$this->machines = array_map(
|
||||
fn (array $m) => [
|
||||
|
|
@ -47,5 +79,18 @@ class DefinitionLab
|
|||
],
|
||||
$donnees['machines'],
|
||||
);
|
||||
// Les commandes et le résultat attendu ne sont lus que par le
|
||||
// correcteur, sur l'hyperviseur : le portail n'en a pas besoin.
|
||||
$this->verifications = array_map(
|
||||
fn (array $v) => [
|
||||
'id' => $v['id'],
|
||||
'titre' => $v['titre'],
|
||||
'machine' => $v['machine'],
|
||||
'points' => (int) ($v['points'] ?? 1),
|
||||
'message_echec' => $v['message_echec'] ?? 'Vérification non réussie.',
|
||||
'bonus' => str_starts_with($v['id'], 'bonus-'),
|
||||
],
|
||||
$donnees['verifications'] ?? [],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue