From d585856d7a8e9acbe05cd5c3e40f071a8ca94b11 Mon Sep 17 00:00:00 2001 From: Shamee Mahmud Date: Wed, 23 Sep 2026 23:26:31 +0000 Subject: [PATCH] Detect ESXi (VMkernel) in discover_and_write_os_family MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `uname -s` returns "VMkernel" on ESXi (exit 0), which currently falls through to OSFamily.LINUX. Map it to OSFamily.ESXI — mirroring the branch already in inbandmanager.py — so the CLI OS-family detection reaches the ESXi code paths in the in-band collectors. Without this, ESXi hosts are misdetected as Linux and every ESXi collector path is skipped. Add a unit test. --- nodescraper/connection/inband/osdetection.py | 2 ++ test/unit/connection/test_osdetection.py | 21 ++++++++++++++++++++ 2 files changed, 23 insertions(+) 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")