Return list of (discovery_dir, username) tuples.
()
| 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. |
| 41 | def _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 | |
| 62 | def load_config() -> Dict[str, Any]: |
no test coverage detected