|
|
|
|
@ -745,6 +745,9 @@ final class CloudPlacementService
|
|
|
|
|
if ($lineId < 1) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
// Management, gateway, DNS and other operator-owned addresses are
|
|
|
|
|
// removed from the ledger when the pool's reserved_ips is materialized.
|
|
|
|
|
// cloud_hosts intentionally has no engine/SSH host-address column.
|
|
|
|
|
$rows = CloudPublicIp::query()->join(
|
|
|
|
|
'cloud_public_ip_pools as public_pool',
|
|
|
|
|
'public_pool.id', '=', 'cloud_public_ips.public_ip_pool_id'
|
|
|
|
|
@ -760,7 +763,6 @@ final class CloudPlacementService
|
|
|
|
|
->whereNull('cloud_public_ips.instance_id')
|
|
|
|
|
->whereNull('cloud_public_ips.operation_id')
|
|
|
|
|
->whereColumn('cloud_public_ips.host_id', 'public_pool.host_id')
|
|
|
|
|
->whereColumn('cloud_public_ips.address', '<>', 'eligible_host.host')
|
|
|
|
|
->whereColumn('cloud_public_ips.prefix_length',
|
|
|
|
|
'public_pool.guest_prefix_length')
|
|
|
|
|
->whereColumn('cloud_public_ips.host_id', 'network_attachment.host_id')
|
|
|
|
|
@ -778,15 +780,9 @@ final class CloudPlacementService
|
|
|
|
|
->distinct()->get([
|
|
|
|
|
'cloud_public_ips.host_id', 'cloud_public_ips.address',
|
|
|
|
|
'public_pool.pool_key', 'public_pool.cidr',
|
|
|
|
|
'eligible_host.host as management_host',
|
|
|
|
|
]);
|
|
|
|
|
$available = [];
|
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
if (CloudPanelUsageService::managementAddressFromValue(
|
|
|
|
|
$row->management_host ?? null
|
|
|
|
|
) === (string) $row->address) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (preg_match('/^[a-f0-9]{32}$/D', (string) $row->pool_key) === 1
|
|
|
|
|
&& self::ipv4BelongsToCidr(
|
|
|
|
|
(string) $row->address, (string) $row->cidr
|
|
|
|
|
|