···622622 deviceNames := make(map[string]bool)
623623624624 for _, pool := range hsmPoolList.Items {
625625- if pool.Status.Phase == hsmv1alpha1.HSMPoolPhaseReady {
626626- // Count actual aggregated physical devices, not just device references
627627- for i, aggregatedDevice := range pool.Status.AggregatedDevices {
628628- if aggregatedDevice.Available {
629629- // Create unique device name for each physical device instance
630630- // This matches the agent naming scheme: deviceRef-i
631631- for _, deviceRef := range pool.Spec.HSMDeviceRefs {
632632- physicalDeviceName := fmt.Sprintf("%s-%d", deviceRef, i)
633633- deviceNames[physicalDeviceName] = true
625625+ if pool.Status.Phase == hsmv1alpha1.HSMPoolPhaseReady && len(pool.Status.AggregatedDevices) > 0 {
626626+ // Use the actual HSMDevice names from the pool spec
627627+ // AgentManager will handle connecting to the appropriate agent instances
628628+ for _, deviceRef := range pool.Spec.HSMDeviceRefs {
629629+ // Only add if there are available devices in this pool
630630+ hasAvailableDevice := false
631631+ for _, aggregatedDevice := range pool.Status.AggregatedDevices {
632632+ if aggregatedDevice.Available {
633633+ hasAvailableDevice = true
634634+ break
634635 }
636636+ }
637637+ if hasAvailableDevice {
638638+ deviceNames[deviceRef] = true
635639 }
636640 }
637641 }