Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use novaconsole to interact with (send keystrokes to) an instance? #4

Open
julianpistorius opened this issue Mar 9, 2022 · 2 comments · May be fixed by #5
Open

Can I use novaconsole to interact with (send keystrokes to) an instance? #4

julianpistorius opened this issue Mar 9, 2022 · 2 comments · May be fixed by #5

Comments

@julianpistorius
Copy link

I'm looking for a way to interact with consoles of OpenStack instances which are inaccessible from the Internet (to help with debugging deployments for example). I've tested this and I can see the console output. When I type anything into the local terminal window running novaconsole it disconnects.

On the instance:

root@serial-console-test:~# echo "I am echoing this into /dev/console from an SSH session on the instance" > /dev/console
root@serial-console-test:~# echo "Now I'm going to type some keys in novaconsole" > /dev/console

On my laptop:

$ nova get-serial-console aaaaaaaa-bbbb-cccc-dddd-eeeeffff0000
+--------+--------------------------------------------------------------------------------+
| Type   | Url                                                                            |
+--------+--------------------------------------------------------------------------------+
| serial | wss://js2.jetstream-cloud.org:6083/?token=deadbeef-dead-beef-dead-beefdeadbeef |
+--------+--------------------------------------------------------------------------------+
$ novaconsole -d -v --url wss://js2.jetstream-cloud.org:6083/?token=deadbeef-dead-beef-dead-beefdeadbeef
WARNING:novaconsole.client:connected to: wss://js2.jetstream-cloud.org:6083/?token=7deadbeef-dead-beef-dead-beefdeadbeef
WARNING:novaconsole.client:type "~." to disconnect
I am echoing this into /dev/console from an SSH session on the instance
Now I'm going to type some keys in novaconsole
ERROR:novaconsole:remote host closed connection: Connection to remote host was lost.

I typed a key on my laptop and then the ERROR:... line was printed.

Is this something which is even possible using Nova serial consoles? Is it something that needs to be configured in Nova?

Background: If this is possible then I'd like to reverse engineer novaconsole to build an in-browser version using xterm.js. I don't want to use the SPICE HTML5 client or noVNC, because I want a proper copy & paste experience in the browser.

Any advice appreciated!

@larsks
Copy link
Owner

larsks commented Mar 9, 2022

Is this something which is even possible using Nova serial consoles?

It should be! When written it was certainly possible to engage in two-way communication with the serial console.

Is it something that needs to be configured in Nova?

Not to my knowledge. It looks like you already have serial console support enabled, which should be sufficient.

It's been a while since I've had the opportunity to work with this code, but it's really just a simple websocket proxy with a thin wrapper to perform the keystone authentication. It should be trivial to implement in a browser (and these days there are a variety of terminal frameworks already available that might take care of terminal emulation for you).

@julianpistorius
Copy link
Author

julianpistorius commented Mar 9, 2022

Thank you @larsks. It's good news that it was possible at some point. I'll use a debugger and see if I can figure out why it's crashing, and why it won't take keyboard input.

Re terminal frameworks: I got xterm.js to work in a duplex fashion with the Docker websocket console. I was hoping to do the same with Nova serial consoles. You can see a video of my efforts on this MR:

https://gitlab.com/exosphere/exosphere/-/merge_requests/619#note_869029857

melwitt added a commit to melwitt/novaconsole that referenced this issue Jun 21, 2022
websockify dropped support for text frames awhile back [1][2], possibly
as of version 0.9.0 [3]. Attempts to send text frames to a sufficiently
new websockify server result in the following error returned:

  Unsupported: Text frames are not supported

and then the server closes the connection.

This changes the client to call Webocket.send_binary() [4] instead of
Websocket.send() in order to send binary data rather than text.

websockify has (always?) supported receiving binary data so this should
be backward compatible with older versions.

Closes larsks#4

[1] novnc/websockify#365
[2] novnc/websockify@8eb5cb0
[3] novnc/websockify@8a69762
[4] https://websocket-client.readthedocs.io/en/latest/core.html#websocket._core.WebSocket.send_binary
@melwitt melwitt linked a pull request Jun 21, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants