82 lines
2.4 KiB
PHP
82 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\DTOs\VirtualMachine\Rebuild;
|
|
|
|
/**
|
|
* Immutable context object carried through the rebuild pipeline.
|
|
*
|
|
* Built fresh by VmRebuildService::buildContext() at the start of every
|
|
* rebuild job so it always reflects the current DB state. Jobs themselves
|
|
* only serialize a few primitive identifiers — they reload context from
|
|
* DB to stay idempotent.
|
|
*/
|
|
final class RebuildContext
|
|
{
|
|
/**
|
|
* @param array{cpu:int,ram:int,disk:int} $addonTotals
|
|
*/
|
|
public function __construct(
|
|
public readonly int $moduleVmwareId,
|
|
public readonly ?int $serviceId,
|
|
public readonly int $customerId,
|
|
public readonly int $newOsId,
|
|
public readonly string $oldVmId,
|
|
public readonly ?string $newVmId,
|
|
public readonly string $vmName,
|
|
public readonly string $transientName,
|
|
public readonly string $ip,
|
|
public readonly string $gateway,
|
|
public readonly string $netmask,
|
|
public readonly int $cidr,
|
|
public readonly string $dns,
|
|
public readonly ?int $moduleIpAddressId,
|
|
public readonly int $vcenterId,
|
|
public readonly int $hostId,
|
|
public readonly bool $isWindows,
|
|
public readonly string $osFamily,
|
|
public readonly string $guestUser,
|
|
public readonly mixed $template,
|
|
public readonly mixed $datacenterRef,
|
|
public readonly mixed $hostRef,
|
|
public readonly int $baseCpu,
|
|
public readonly int $baseRam,
|
|
public readonly int $baseDisk,
|
|
public readonly array $addonTotals,
|
|
) {
|
|
}
|
|
|
|
public function withNewVmId(string $newVmId): self
|
|
{
|
|
return new self(
|
|
$this->moduleVmwareId,
|
|
$this->serviceId,
|
|
$this->customerId,
|
|
$this->newOsId,
|
|
$this->oldVmId,
|
|
$newVmId,
|
|
$this->vmName,
|
|
$this->transientName,
|
|
$this->ip,
|
|
$this->gateway,
|
|
$this->netmask,
|
|
$this->cidr,
|
|
$this->dns,
|
|
$this->moduleIpAddressId,
|
|
$this->vcenterId,
|
|
$this->hostId,
|
|
$this->isWindows,
|
|
$this->osFamily,
|
|
$this->guestUser,
|
|
$this->template,
|
|
$this->datacenterRef,
|
|
$this->hostRef,
|
|
$this->baseCpu,
|
|
$this->baseRam,
|
|
$this->baseDisk,
|
|
$this->addonTotals,
|
|
);
|
|
}
|
|
}
|