Switch the active VMM instance.
(args)
| 227 | |
| 228 | |
| 229 | def 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 | |
| 260 | def encrypt_env(envs, hex_public_key: str) -> str: |
no test coverage detected