find($item->os_id); if (!$os) { throw new RuntimeException( "Không tìm thấy OS id={$item->os_id} trong OrderItem #{$item->id}. os_id không hợp lệ." ); } $chain = $this->activeProvider->resolveChain(); $this->logger->step('Infrastructure resolved from active chain', [ 'order_item_id' => $item->id, 'vcenter_id' => $chain['vcenter']->id, 'datacenter_id' => $chain['datacenter']->id, 'host_id' => $chain['host']->id, 'datastore_id' => $chain['datastore']->id, 'network_id' => $chain['network']->id, ]); $osGroupName = $os->osGroup?->name ?? ''; $isWindows = str_contains(strtolower($osGroupName), 'windows'); return new VmInfrastructureContext( os: $os, host: $chain['host'], datacenter: $chain['datacenter'], vcenter: $chain['vcenter'], template: $os->template_id, isWindows: $isWindows, vmUser: $isWindows ? 'administrator' : 'root', vmPort: $isWindows ? 3389 : 22, datastore: $chain['datastore'], network: $chain['network'], ); } }