60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Provisioning\Steps\Customer;
|
|
|
|
use App\Models\ProvisioningRun;
|
|
use App\Provisioning\StepResult;
|
|
use App\Services\Proxmox\ProxmoxClient;
|
|
use App\Services\Traefik\TraefikWriter;
|
|
|
|
/**
|
|
* Gate: nothing grants the customer access until every check here passes.
|
|
*/
|
|
class RunAcceptanceChecks extends CustomerStep
|
|
{
|
|
public function __construct(
|
|
private ProxmoxClient $pve,
|
|
private TraefikWriter $traefik,
|
|
) {}
|
|
|
|
public function key(): string
|
|
{
|
|
return 'run_acceptance_checks';
|
|
}
|
|
|
|
public function maxDuration(): int
|
|
{
|
|
return 180;
|
|
}
|
|
|
|
public function execute(ProvisioningRun $run): StepResult
|
|
{
|
|
$instance = $this->instance($run);
|
|
$node = (string) $run->context('node');
|
|
$vmid = (int) $run->context('vmid');
|
|
$fqdn = $instance->subdomain.'.'.config('provisioning.dns.zone');
|
|
|
|
if (! $instance->cert_ok || ! $this->traefik->certReachable($fqdn)) {
|
|
return StepResult::fail('acceptance_failed:cert');
|
|
}
|
|
|
|
$status = $this->pve->forHost($instance->host)
|
|
->guestExec($node, $vmid, 'curl -sf http://localhost/status.php');
|
|
if ((int) ($status['exitcode'] ?? 1) !== 0) {
|
|
return StepResult::fail('acceptance_failed:nextcloud');
|
|
}
|
|
|
|
if (! $this->hasResource($run, 'nc_admin')) {
|
|
return StepResult::fail('acceptance_failed:admin');
|
|
}
|
|
if (! $this->hasResource($run, 'backup_job_id')) {
|
|
return StepResult::fail('acceptance_failed:backup');
|
|
}
|
|
if (! $this->hasResource($run, 'monitoring_target_id')) {
|
|
return StepResult::fail('acceptance_failed:monitoring');
|
|
}
|
|
|
|
return StepResult::advance();
|
|
}
|
|
}
|