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

Function cmd_switch_vmm

vmm/src/vmm-cli.py:229–257  ·  view source on GitHub ↗

Switch the active VMM instance.

(args)

Source from the content-addressed store, hash-verified

227
228
229def cmd_switch_vmm(args):
230 """Switch the active VMM instance."""
231 target = args.vmm_id
232 instances = discover_vmm_instances()
233
234 if not instances:
235 print("No running VMM instances found.")
236 return
237
238 # Find matching instance by prefix
239 matches = [i for i in instances if i["id"].startswith(target)]
240 if len(matches) == 0:
241 print(f"No VMM instance matching '{target}'.")
242 print("Available instances:")
243 for inst in instances:
244 print(
245 f" {inst['id'][:8]} {inst.get('address', '?')} {inst.get('working_dir', '?')}"
246 )
247 return
248 if len(matches) > 1:
249 print(f"Ambiguous ID '{target}', matches multiple instances:")
250 for inst in matches:
251 print(f" {inst['id'][:8]} {inst.get('address', '?')}")
252 return
253
254 selected = matches[0]
255 save_active_vmm(selected["id"])
256 url = vmm_address_to_url(selected)
257 print(f"Switched to VMM {selected['id'][:8]} ({url})")
258
259
260def encrypt_env(envs, hex_public_key: str) -> str:

Callers 1

mainFunction · 0.85

Calls 4

discover_vmm_instancesFunction · 0.85
save_active_vmmFunction · 0.85
vmm_address_to_urlFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected