diff --git a/nodescraper/connection/inband/osdetection.py b/nodescraper/connection/inband/osdetection.py index 84fbb66c..2441cf48 100644 --- a/nodescraper/connection/inband/osdetection.py +++ b/nodescraper/connection/inband/osdetection.py @@ -186,6 +186,8 @@ def discover_and_write_os_family( res = connection_manager.connection.run_command("uname -s") if "not recognized as an internal or external command" in res.stdout + res.stderr: system_info.os_family = OSFamily.WINDOWS + elif res.exit_code == 0 and "VMkernel" in res.stdout: + system_info.os_family = OSFamily.ESXI elif res.exit_code == 0: system_info.os_family = OSFamily.LINUX else: diff --git a/test/unit/connection/test_osdetection.py b/test/unit/connection/test_osdetection.py index ca445317..7b53d18f 100644 --- a/test/unit/connection/test_osdetection.py +++ b/test/unit/connection/test_osdetection.py @@ -238,3 +238,24 @@ def test_discover_and_write_os_family_linux_skips_network_probes(system_info, co assert system_info.os_family == OSFamily.LINUX conn_mock.run_command.assert_called_once_with("uname -s") + + +DUMMY_UNAME_ESXI = CommandArtifact( + command="uname -s", + stdout="VMkernel", + stderr="", + exit_code=0, +) + + +def test_discover_and_write_os_family_detects_esxi(system_info, conn_mock, logger): + """ESXi reports 'VMkernel' from `uname -s` (exit 0); classify it as ESXI and + skip the network-OS probes (same fast path as Linux).""" + manager = InBandConnectionManager(system_info=system_info) + manager.connection = conn_mock + conn_mock.run_command.return_value = DUMMY_UNAME_ESXI + + discover_and_write_os_family(manager, system_info, logger) + + assert system_info.os_family == OSFamily.ESXI + conn_mock.run_command.assert_called_once_with("uname -s")