ajoute le self-healing des VM (sonde de santé, relance automatique, stock écarté) — bloc A, semaine 6

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Adam Belkacemi 2026-10-12 21:12:43 +02:00
parent b054888f5a
commit f2649d0f8b
21 changed files with 938 additions and 28 deletions

View file

@ -30,4 +30,35 @@ class NovaClient
return $reponse->json('remote_console.url');
}
/**
* Redémarrage forcé (bloc A, self-healing) : équivalent d'un appui sur
* le bouton reset. Le disque de la VM est conservé.
*/
public function redemarrerForce(string $instanceId): void
{
$this->action($instanceId, ['reboot' => ['type' => 'HARD']]);
}
/** Démarre une VM éteinte (l'élève a lancé « poweroff »). */
public function demarrer(string $instanceId): void
{
$this->action($instanceId, ['os-start' => null]);
}
/**
* @param array<string, mixed> $corps
*/
private function action(string $instanceId, array $corps): void
{
$reponse = Http::withHeaders([
'X-Auth-Token' => $this->auth->jeton(),
'OpenStack-API-Version' => 'compute 2.99',
])
->post(config('openstack.nova_url')."/servers/{$instanceId}/action", $corps);
if ($reponse->failed()) {
throw new RuntimeException("Nova a refusé l'action ".array_key_first($corps)." sur {$instanceId} : ".$reponse->body());
}
}
}