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

Function cmd_ls_vmm

vmm/src/vmm-cli.py:177–226  ·  view source on GitHub ↗

List all discovered VMM instances.

(args)

Source from the content-addressed store, hash-verified

175
176
177def cmd_ls_vmm(args):
178 """List all discovered VMM instances."""
179 instances = discover_vmm_instances()
180 config = load_config()
181 active_id = config.get("active_vmm")
182
183 if not instances:
184 print("No running VMM instances found.")
185 print(
186 f" (scanned: {', '.join(d for d, _ in _get_discovery_dirs()) or '/run/user/*/dstack-vmm'})"
187 )
188 return
189
190 if getattr(args, "json", False):
191 print(json.dumps(instances, indent=2))
192 return
193
194 # Table output
195
196 fmt = " {active} {id:<12s} {pid:<8s} {user:<10s} {node:<12s} {address:<24s} {workdir}"
197 print(
198 fmt.format(
199 active="",
200 id="ID",
201 pid="PID",
202 user="USER",
203 node="NAME",
204 address="ADDRESS",
205 workdir="WORKING DIR",
206 )
207 )
208 print(" " + "-" * 100)
209
210 for inst in instances:
211 short_id = inst["id"][:8]
212 is_active = "*" if active_id and inst["id"].startswith(active_id) else " "
213 node_name = inst.get("node_name", "") or "-"
214 address = inst.get("address", "?")
215
216 print(
217 fmt.format(
218 active=is_active,
219 id=short_id,
220 pid=str(inst.get("pid", "?")),
221 user=inst.get("user", "?")[:10],
222 node=node_name[:12],
223 address=address[:24],
224 workdir=inst.get("working_dir", "?"),
225 )
226 )
227
228
229def cmd_switch_vmm(args):

Callers 1

mainFunction · 0.85

Calls 4

discover_vmm_instancesFunction · 0.85
_get_discovery_dirsFunction · 0.85
load_configFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected