diff --git a/backend/app/services/device_discovery.py b/backend/app/services/device_discovery.py index 6e8c406..f496fc9 100644 --- a/backend/app/services/device_discovery.py +++ b/backend/app/services/device_discovery.py @@ -507,7 +507,9 @@ async def discover_via_ssh( continue # Add the rack itself as a main_server device if it doesn't exist - logger.info(f"[ssh_discovery] Processing rack {rack_host} ({rack_name})") + # Use external_id (e.g., "lane-1-1") as the hostname + rack_hostname = external_id + logger.info(f"[ssh_discovery] Processing rack {rack_host} ({rack_hostname})") try: existing_rack = (await db.execute( select(Device).where( @@ -517,7 +519,6 @@ async def discover_via_ssh( )).scalar_one_or_none() if existing_rack is None: - rack_hostname = f"rack{rack_name}" db.add(Device( object_id=obj.id, ip=rack_host, @@ -552,7 +553,7 @@ async def discover_via_ssh( result.errors.append(f"Error adding rack {rack_host}: {exc}") result.actions.append(DeviceAction( ip=rack_host, - hostname=f"rack{rack_name}", + hostname=rack_hostname, action="ERROR", reason=str(exc), category="embedded",