MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / _get_discovery_dirs

Function _get_discovery_dirs

vmm/src/vmm-cli.py:41–59  ·  view source on GitHub ↗

Return list of (discovery_dir, username) tuples.

()

Source from the content-addressed store, hash-verified

39# Each user's instances are in $XDG_RUNTIME_DIR/dstack-vmm (typically /run/user/<uid>/dstack-vmm).
40# CLI scans all users' directories so operators can see every instance on the host.
41def _get_discovery_dirs() -> List[Tuple[str, Optional[str]]]:
42 """Return list of (discovery_dir, username) tuples."""
43 import pwd
44
45 dirs = []
46 run_user = "/run/user"
47 if os.path.isdir(run_user):
48 try:
49 for uid_str in os.listdir(run_user):
50 candidate = os.path.join(run_user, uid_str, "dstack-vmm")
51 if os.path.isdir(candidate):
52 try:
53 username = pwd.getpwuid(int(uid_str)).pw_name
54 except (KeyError, ValueError):
55 username = f"uid:{uid_str}"
56 dirs.append((candidate, username))
57 except PermissionError:
58 pass
59 return dirs
60
61
62def load_config() -> Dict[str, Any]:

Callers 2

discover_vmm_instancesFunction · 0.85
cmd_ls_vmmFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected