[lxc-users] Window resize
alexandros giavaras
a.giavaras at gmail.com
Sat Jan 18 14:47:26 UTC 2020
Hi all,
I have been using pylxd to interact LXD REST API. I create a container and
then send
the /bin/bash cmd using the raw_interactive_execute function.
Concretely here is my function call
res = container.raw_interactive_execute(['/bin/bash', ],
environment={"TERM":"xterm"})
I got back the websocket secret and the control. So far so good. I am
opening a websocket to
interact with the container as follows:
websocket.enableTrace(False)
ws = websocket.WebSocketApp(uri,
on_message=on_message,
on_error=on_error,
on_close=on_close,
on_open=on_open)
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}, ping_interval=0,
ping_timeout=0)
ws.close()
Here is also the on_open
def on_open(ws):
def run(*args):
while True:
cmd = get_user_input()
cmd += "\r"
print("Sending CMD: ", cmd)
cmd = bytearray(cmd, encoding='utf-8')
ws.send(cmd, opcode=2)
time.sleep(1)
print("Closing connection...")
ws.close()
print("thread terminating...")
thread.start_new_thread(run, ())
I then open the control as follows
uri = 'some_uri_generated'
websocket.enableTrace(False)
ws = websocket.WebSocketApp(uri,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}, ping_interval=0,
ping_timeout=0)
ws.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20200118/e888942d/attachment.html>
More information about the lxc-users
mailing list