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

Function vmm_address_to_url

vmm/src/vmm-cli.py:148–165  ·  view source on GitHub ↗

Convert a VMM instance info dict to a connection URL.

(instance: Dict[str, Any])

Source from the content-addressed store, hash-verified

146
147
148def vmm_address_to_url(instance: Dict[str, Any]) -> str:
149 """Convert a VMM instance info dict to a connection URL."""
150 addr = instance.get("address", "")
151 if addr.startswith("unix:"):
152 # Resolve relative socket path against working directory
153 socket_path = addr[5:]
154 if not os.path.isabs(socket_path):
155 working_dir = instance.get("working_dir", "")
156 socket_path = os.path.join(working_dir, socket_path)
157 return f"unix:{socket_path}"
158 elif addr.startswith("http://") or addr.startswith("https://"):
159 return addr
160 else:
161 # host:port format from discovery
162 host, _, port = addr.rpartition(":")
163 if host == "0.0.0.0":
164 host = "127.0.0.1"
165 return f"http://{host}:{port}"
166
167
168def save_active_vmm(vmm_id: str):

Callers 2

resolve_vmm_urlFunction · 0.85
cmd_switch_vmmFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected