Files
nova/doc/source/testing/serial-console.rst
Joe Gordon a1e8fc6dd9 Update docs layout
* Explain these docs are for trunk (copied from ironic)
* All the docs in this repo are meant to be developer docs, so having a
  devref inside of the docs is redundant and just makes the docs more
  complicated to navigate. Move everything out of the devref folder and
  link to everything from main index.
* Move man pages into separate section. The man pages are pretty sparse
* right now, we should either make them useful or just delete them
* Remove dead docs from unused_docs list in doc/source/conf.py
* Shuffle docs landing page, move common referees to the top (API,
  hypervisor support matrix), Add a introduction section and more. The
  hope is the updated layout makes this document easier to navigate.
* Use maxdepth of 1
* Rename a few sections with what are hopefully better names

The next step is to prune out outdated documents and further cleanup
this page.

Change-Id: Iff453e47ccc902a0e72b1a5f6ce1ee939ff3a1a0
2015-05-15 10:47:18 -07:00

2.7 KiB

Testing Serial Console

The main aim of this feature is exposing an interactive web-based serial consoles through a web-socket proxy. This page describes how to test it from a devstack environement.

Setting up a devstack environment

For instructions on how to setup devstack with serial console support enabled see this guide.

Testing the API

Starting a new instance.

# cd devstack && . openrc
# nova boot --flavor 1 --image cirros-0.3.2-x86_64-uec cirros1

Nova provides a command nova get-serial-console which will returns a URL with a valid token to connect to the serial console of VMs.

# nova get-serial-console cirros1
+--------+-----------------------------------------------------------------+
| Type   | Url                                                             |
+--------+-----------------------------------------------------------------+
| serial | ws://127.0.0.1:6083/?token=5f7854b7-bf3a-41eb-857a-43fc33f0b1ec |
+--------+-----------------------------------------------------------------+

Currently nova does not provide any client able to connect from an interactive console through a web-socket. A simple client for test purpose can be written with few lines of Python.

# sudo easy_install ws4py || sudo pip install ws4py
# cat >> client.py <<EOF
import sys
from ws4py.client.threadedclient import WebSocketClient
class LazyClient(WebSocketClient):
    def run(self):
        try:
            while not self.terminated:
                try:
                    b = self.sock.recv(4096)
                    sys.stdout.write(b)
                    sys.stdout.flush()
                except: # socket error expected
                    pass
        finally:
            self.terminate()
if __name__ == '__main__':
    if len(sys.argv) != 2 or not sys.argv[1].startswith("ws"):
        print "Usage %s: Please use websocket url"
        print "Example: ws://127.0.0.1:6083/?token=xxx"
        exit(1)
    try:
        ws = LazyClient(sys.argv[1], protocols=['binary'])
        ws.connect()
        while True:
            # keyboard event...
            c = sys.stdin.read(1)
            if c:
                ws.send(c)
        ws.run_forever()
    except KeyboardInterrupt:
        ws.close()
EOF
# python client.py ws://127.0.0.1:6083/?token=5f7854b7-bf3a-41eb-857a-43fc33f0b1ec
<enter>
cirros1 login