Skip to content

Commit 6792848

Browse files
committed
firecracker.py: accept host/port/password and console object
1 parent 628d859 commit 6792848

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

firecracker.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ def op_console(ctx):
367367
"""POST /v1/vms/{name}/console — obtain VNC bridge connection info."""
368368
url = f"{ctx.agent.base_url}/vms/{ctx.vm_name}/console"
369369
data = _json_or_fail(_req("POST", url, ctx.agent))
370+
console_obj = data.get("console")
371+
if isinstance(console_obj, dict):
372+
host = console_obj.get("host")
373+
port = console_obj.get("port")
374+
password = console_obj.get("password")
375+
if host and port and password:
376+
try:
377+
console_obj["port"] = int(port)
378+
except (TypeError, ValueError):
379+
_fail(f"Invalid port value returned by agent: {port}")
380+
_ok(data)
381+
# fallthrough if malformed
370382
console_host = getattr(ctx.agent, "console_host", "") or ""
371383
resp_host = data.get("host")
372384
if console_host and (not resp_host or resp_host in {"0.0.0.0", "127.0.0.1", "::"}):

0 commit comments

Comments
 (0)