MCPcopy Create free account
hub / github.com/compassvpn/agent / get_machine_id

Function get_machine_id

shared_lib/system.py:8–23  ·  view source on GitHub ↗

Retrieves the machine ID from the host system.

()

Source from the content-addressed store, hash-verified

6from shared_lib.logger import log
7
8
9def get_machine_id() -> str:
10 """Retrieves the machine ID from the host system."""
11 paths = ["/host/etc/machine-id", "/etc/machine-id"]
12 for path in paths:
13 if os.path.exists(path):
14 with open(path, "r", encoding="utf-8") as f:
15 machine_id = f.read().strip()
16 log.debug(
17 "Machine ID retrieved",
18 hypothesisId="SYS",
19 path=path,
20 id=machine_id,
21 )
22 return machine_id
23 log.debug("Failed to retrieve machine ID", hypothesisId="SYS", checked_paths=paths)
24 raise RuntimeError("Failed to retrieve machine ID: No valid machine-id file found.")
25
26

Callers 1

update_metricsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected