fix: add queues property to network configuration and implement CPU core retrieval method

This commit is contained in:
2025-12-04 21:41:05 -05:00
parent 7985b894e4
commit 9836f321c1
2 changed files with 28 additions and 2 deletions

View File

@@ -18,6 +18,8 @@ class Network extends Component
public array $disconnectedConfigs = [];
public array $interfaceMultiqueues = [];
public string $interfaceType = 'virtio';
public string $selectedInterface = 'net0';
@@ -83,6 +85,7 @@ class Network extends Component
$mac = null;
$mtu = null;
$linkdown = false;
$queues = 1;
foreach ($segments as $segment) {
if (!str_contains($segment, '=')) {
@@ -100,6 +103,8 @@ class Network extends Component
$mtu = $segmentValue;
} elseif (strtolower($segmentKey) === 'link_down' || strtolower($segmentKey) === 'linkdown') {
$linkdown = (bool) $segmentValue;
} elseif (strtolower($segmentKey) === 'queues') {
$queues = max(1, (int) $segmentValue);
}
}
@@ -108,6 +113,7 @@ class Network extends Component
'mac' => $mac,
'mtu' => $mtu,
'linkdown' => $linkdown,
'queues' => $queues,
];
}
@@ -119,6 +125,7 @@ class Network extends Component
$model = 'virtio';
$mac = null;
$mtu = null;
$queues = 1;
foreach ($segments as $segment) {
if (!str_contains($segment, '=')) {
@@ -134,6 +141,8 @@ class Network extends Component
continue;
} elseif (strtolower($segmentKey) === 'mtu') {
$mtu = $segmentValue;
} elseif (strtolower($segmentKey) === 'queues') {
$queues = max(1, (int) $segmentValue);
}
}
@@ -142,6 +151,7 @@ class Network extends Component
'mac' => $mac,
'mtu' => $mtu,
'linkdown' => true,
'queues' => $queues,
];
}
}
@@ -153,6 +163,7 @@ class Network extends Component
'mac' => null,
'mtu' => null,
'linkdown' => false,
'queues' => 1,
],
];
$configs = ['net0' => ''];
@@ -171,6 +182,7 @@ class Network extends Component
'mac' => null,
'mtu' => null,
'linkdown' => false,
'queues' => 1,
],
];
$configs = ['net0' => ''];
@@ -270,6 +282,22 @@ class Network extends Component
return '/' . $bits;
}
public function getCpuCores(): int
{
try {
$proxmox = new Proxmox;
$config = $proxmox->request('/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config')->json()['data'] ?? [];
// CPU cores can be specified with 'cores' or 'cpus' in Proxmox config
$cores = (int) ($config['cores'] ?? $config['cpus'] ?? 1);
return max(1, $cores);
} catch (\Exception $e) {
// Fallback to 1 if unable to retrieve
return 1;
}
}
public function isPublicIp($ip, $type = 'ipv4')
{
if ($type === 'ipv6' || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {

View File

@@ -5851,8 +5851,6 @@ filter strict_import {
</div>
</div>
</div>
</div>
</div>
</div>
</div>