Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nodescraper/connection/inband/osdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions test/unit/connection/test_osdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading