Skip to content

Commit 8cb9a7f

Browse files
Merge pull request #299 from amd/esxi-osdetection-vmkernel
Detect ESXi (VMkernel) in discover_and_write_os_family
2 parents e615698 + 8ef7540 commit 8cb9a7f

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎nodescraper/connection/inband/osdetection.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ def discover_and_write_os_family(
186186
res = connection_manager.connection.run_command("uname -s")
187187
if "not recognized as an internal or external command" in res.stdout + res.stderr:
188188
system_info.os_family = OSFamily.WINDOWS
189+
elif res.exit_code == 0 and "VMkernel" in res.stdout:
190+
system_info.os_family = OSFamily.ESXI
189191
elif res.exit_code == 0:
190192
system_info.os_family = OSFamily.LINUX
191193
else:

‎test/unit/connection/test_osdetection.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,24 @@ def test_discover_and_write_os_family_linux_skips_network_probes(system_info, co
238238

239239
assert system_info.os_family == OSFamily.LINUX
240240
conn_mock.run_command.assert_called_once_with("uname -s")
241+
242+
243+
DUMMY_UNAME_ESXI = CommandArtifact(
244+
command="uname -s",
245+
stdout="VMkernel",
246+
stderr="",
247+
exit_code=0,
248+
)
249+
250+
251+
def test_discover_and_write_os_family_detects_esxi(system_info, conn_mock, logger):
252+
"""ESXi reports 'VMkernel' from `uname -s` (exit 0); classify it as ESXI and
253+
skip the network-OS probes (same fast path as Linux)."""
254+
manager = InBandConnectionManager(system_info=system_info)
255+
manager.connection = conn_mock
256+
conn_mock.run_command.return_value = DUMMY_UNAME_ESXI
257+
258+
discover_and_write_os_family(manager, system_info, logger)
259+
260+
assert system_info.os_family == OSFamily.ESXI
261+
conn_mock.run_command.assert_called_once_with("uname -s")

0 commit comments

Comments
 (0)