'preserved', 'guest_hostname' => 'retained.example', 'platform_network_policy_snapshot' => ['version' => 1], 'vcpu' => 1, 'cpu_cores' => 1, 'memory_mib' => 1024, 'ram_mib' => 1024, 'disk_gib' => 20, 'bandwidth_mbps' => 100, 'network' => 'bridge:br0', 'public_pool_key' => str_repeat('a', 32), 'public_pool_cidr' => '198.51.100.0/24', 'public_ip_cidr' => '198.51.100.10/24', 'public_ip' => '198.51.100.10', 'gateway' => '198.51.100.1', 'dns_servers' => ['1.1.1.1'], ]; $body = [ 'vcpu' => 4, 'memory_mib' => 8192, 'disk_gib' => 80, 'bandwidth_mbps' => 500, 'network' => 'bridge:line-b', 'public_pool_key' => str_repeat('b', 32), 'public_pool_cidr' => '203.0.113.0/24', 'public_ip_cidr' => '203.0.113.20/24', 'gateway' => '203.0.113.1', 'dns_servers' => ['9.9.9.9', '149.112.112.112'], ]; $vm = $body + [ 'uuid' => '22222222-2222-4222-8222-222222222222', 'managed' => true, ]; $finalize = new ReflectionMethod( CloudInstanceMigrationService::class, 'finalizeTargetSpec' ); $spec = $finalize->invoke(null, $source, $body, $vm, 202); $assert(($spec['billing_marker'] ?? null) === 'preserved' && ($spec['guest_hostname'] ?? null) === 'retained.example' && ($spec['platform_network_policy_snapshot'] ?? null) === ['version' => 1] && ($spec['vcpu'] ?? null) === 4 && ($spec['cpu_cores'] ?? null) === 4 && ($spec['memory_mib'] ?? null) === 8192 && ($spec['ram_mib'] ?? null) === 8192 && ($spec['disk_gib'] ?? null) === 80 && ($spec['bandwidth_mbps'] ?? null) === 500 && ($spec['network'] ?? null) === 'bridge:line-b' && ($spec['public_pool_key'] ?? null) === str_repeat('b', 32) && ($spec['public_pool_cidr'] ?? null) === '203.0.113.0/24' && ($spec['public_ip_cidr'] ?? null) === '203.0.113.20/24' && ($spec['public_ip'] ?? null) === '203.0.113.20' && ($spec['gateway'] ?? null) === '203.0.113.1' && ($spec['dns_servers'] ?? null) === ['9.9.9.9', '149.112.112.112'] && ($spec['resource_pool_id'] ?? null) === 202, 'Maintenance migration did not converge every target resource and network snapshot field.'); foreach ([ 'vcpu' => 8, 'bandwidth_mbps' => 1000, 'public_pool_cidr' => '203.0.114.0/24', 'gateway' => '203.0.113.2', 'dns_servers' => ['8.8.8.8'], 'network' => 'network:other-line', ] as $field => $different) { $mismatched = array_replace($vm, [$field => $different]); $rejected = false; try { $finalize->invoke(null, $source, $body, $mismatched, 202); } catch (CloudError $error) { $rejected = $error->httpStatus === 502; } $assert($rejected, 'Maintenance migration accepted mismatched Agent field: ' . $field); } echo "Maintenance migration target resource/network snapshot tests passed.\n";