Search code examples
pythonopenstackvnc

How to get the VNC url from openstacksdk


As we know, the OpenStack provides the CLI to show the URL of the VNC console.

For example:

openstack console url show instance_name

Currently, I want to access the console via OpenStack Python SDK but I can't find any APIs to do it.

The question is how I can use OpenStack Python SDK to get the URL of the VNC console of an instance?


Solution

  • If you run openstack --debug ... you will exactly what REST API requests the tool is making. You can also check the api reference, which for recent versions of Nova suggests that you should use the server remote consoles api (and also describes deprecated APIs available in earlier releases).

    If you're using the Python SDK, a simple search of the code reveals that server objects have a get_vnc_console method that will do what you want.