如何从 openstacksdk 获取 VNC url

How to get the VNC url from openstacksdk

众所周知,OpenStack 提供了CLI 来显示VNC 控制台的URL。

例如:

openstack console url show instance_name

目前,我想通过 OpenStack Python SDK 访问控制台,但找不到任何 API 来执行此操作。

问题是如何使用OpenStack Python SDK获取实例VNC控制台的URL?

如果您 运行 openstack --debug ... 您将完全了解该工具正在发出的 REST API 请求。您还可以检查 api reference, which for recent versions of Nova suggests that you should use the server remote consoles api(并且还描述了早期版本中已弃用的 API)。

如果您使用的是 Python SDK,只需搜索一下代码就会发现服务器对象有一个 get_vnc_console 方法可以执行您想要的操作。