Skip to content

Commit dac8ad8

Browse files
committed
Wrap console response for CloudStack
1 parent f0f0592 commit dac8ad8

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

firecracker.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,28 @@ def op_console(ctx):
371371
resp_host = data.get("host")
372372
if console_host and (not resp_host or resp_host in {"0.0.0.0", "127.0.0.1", "::"}):
373373
data["host"] = console_host
374-
_ok(data)
374+
host = data.get("host")
375+
port = data.get("port")
376+
password = data.get("password")
377+
if not host or not port or not password:
378+
_fail("Agent response missing host/port/password for console")
379+
try:
380+
port_int = int(port)
381+
except (TypeError, ValueError):
382+
_fail(f"Invalid port value returned by agent: {port}")
383+
console_obj = {
384+
"host": host,
385+
"port": port_int,
386+
"password": password,
387+
"protocol": "vnc",
388+
"passwordonetimeuseonly": False,
389+
}
390+
response = {
391+
"status": data.get("status", "success"),
392+
"message": data.get("message", "Console ready"),
393+
"console": console_obj,
394+
}
395+
_ok(response)
375396

376397
# -------------------------- main --------------------------
377398
def main():

0 commit comments

Comments
 (0)