feat(vm): hoàn tiền khi cấp VM lỗi, theo dõi job queue, uuid dịch vụ cho ticket, chuẩn hoá RAM addon

- VmProvisionException/VmProvisionRefund xử lý lỗi cấp phát VM
- QueueJobInspector + QueueMonitorController xem chi tiết job
- Thêm service uuid cho ticket, thời lượng cho activity_logs
- Migration chuẩn hoá RAM addon sang MB, trạng thái deleting cho snapshot

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-30 11:54:05 +07:00
co-authored by Claude Sonnet 5.5
parent 7136bec265
commit 62596d9063
32 changed files with 514 additions and 107 deletions
@@ -14,8 +14,8 @@ use RuntimeException;
*
* active vCenter → active Datacenter → active Host → active Datastore + Network
*
* Product/OS host binding is informational only — it no longer drives VM
* creation. Datastore, network, resource pool and folder are exceptions: if
* The OS host (and its datacenter) overrides the active host when set, because the
* OS template, datastore, network, resource pool and folder belong to that host. Datastore, network, resource pool and folder are exceptions: if
* the OS has datastore_id / module_network_id / resource_pool_id / folder_id
* set, they override the active chain / global default (an OS can target a
* different datastore/IP pool/resource pool/folder than whatever happens to
@@ -32,7 +32,7 @@ class VmInfrastructureResolver
public function resolve(OrderItem $item, $product): VmInfrastructureContext
{
$os = Os::with(['osGroup', 'network', 'datastore', 'resourcePool', 'folder'])->find($item->os_id);
$os = Os::with(['osGroup', 'host.datacenter', 'network', 'datastore', 'resourcePool', 'folder'])->find($item->os_id);
if (!$os) {
throw new RuntimeException(
@@ -41,6 +41,8 @@ class VmInfrastructureResolver
}
$chain = $this->activeProvider->resolveChain();
$host = $os->host ?? $chain['host'];
$datacenter = $os->host?->datacenter ?? $chain['datacenter'];
$network = $os->network ?? $chain['network'];
$datastore = $os->datastore ?? $chain['datastore'];
$folderId = $os->folder?->folder ?? $this->providerSettings->defaultFolder();
@@ -50,7 +52,8 @@ class VmInfrastructureResolver
'order_item_id' => $item->id,
'vcenter_id' => $chain['vcenter']->id,
'datacenter_id' => $chain['datacenter']->id,
'host_id' => $chain['host']->id,
'host_id' => $host->id,
'host_from_os' => $os->host !== null,
'datastore_id' => $datastore->id,
'datastore_from_os' => $os->datastore !== null,
'network_id' => $network->id,
@@ -66,8 +69,8 @@ class VmInfrastructureResolver
return new VmInfrastructureContext(
os: $os,
host: $chain['host'],
datacenter: $chain['datacenter'],
host: $host,
datacenter: $datacenter,
vcenter: $chain['vcenter'],
template: $os->template_id,
isWindows: $isWindows,