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

Function main

vmm/src/vmm-cli.py:1504–2020  ·  view source on GitHub ↗

Parse arguments and dispatch to the appropriate command handler.

()

Source from the content-addressed store, hash-verified

1502
1503
1504def main():
1505 """Parse arguments and dispatch to the appropriate command handler."""
1506 parser = argparse.ArgumentParser(description="dstack-vmm CLI - Manage VMs")
1507
1508 # Load config file defaults
1509 config = load_config()
1510
1511 # Discover running VMM instances
1512 instances = discover_vmm_instances()
1513
1514 # Priority: command line > environment variable > config file > auto-discovery > default
1515 default_url = os.environ.get(
1516 "DSTACK_VMM_URL", config.get("url", "http://localhost:8080")
1517 )
1518 default_auth_user = os.environ.get("DSTACK_VMM_AUTH_USER", config.get("auth_user"))
1519 default_auth_password = os.environ.get(
1520 "DSTACK_VMM_AUTH_PASSWORD", config.get("auth_password")
1521 )
1522
1523 parser.add_argument(
1524 "--url",
1525 default=default_url,
1526 help="dstack-vmm API URL (can also be set via DSTACK_VMM_URL env var or config file)",
1527 )
1528
1529 # Basic authentication arguments
1530 parser.add_argument(
1531 "--auth-user",
1532 default=default_auth_user,
1533 help="Basic auth username (can also be set via DSTACK_VMM_AUTH_USER env var or config file)",
1534 )
1535 parser.add_argument(
1536 "--auth-password",
1537 default=default_auth_password,
1538 help="Basic auth password (can also be set via DSTACK_VMM_AUTH_PASSWORD env var or config file)",
1539 )
1540
1541 subparsers = parser.add_subparsers(dest="command", help="Commands")
1542
1543 # VMM discovery commands (vmm ls / vmm switch)
1544 vmm_parser = subparsers.add_parser(
1545 "vmm", help="VMM instance management (ls, switch)"
1546 )
1547 vmm_subparsers = vmm_parser.add_subparsers(
1548 dest="vmm_command", help="VMM sub-commands"
1549 )
1550
1551 vmm_ls_parser = vmm_subparsers.add_parser(
1552 "ls", help="List all running VMM instances on this host"
1553 )
1554 vmm_ls_parser.add_argument(
1555 "--json", action="store_true", help="Output in JSON format"
1556 )
1557
1558 vmm_switch_parser = vmm_subparsers.add_parser(
1559 "switch", help="Switch active VMM instance"
1560 )
1561 vmm_switch_parser.add_argument(

Callers 1

vmm-cli.pyFile · 0.70

Calls 15

list_vmsMethod · 0.95
show_infoMethod · 0.95
start_vmMethod · 0.95
stop_vmMethod · 0.95
remove_vmMethod · 0.95
resize_vmMethod · 0.95
show_logsMethod · 0.95
create_app_composeMethod · 0.95
create_vmMethod · 0.95
list_imagesMethod · 0.95
list_gpusMethod · 0.95
update_vm_envMethod · 0.95

Tested by

no test coverage detected