虚拟机相关接口

获取虚拟机控制台地址和访问协议

GET/zstack/v1/vm-instances/{uuid}/console-addresses

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 5c66c9a616334283b055d150680fff98" \
-X GET http://localhost:8080/zstack/v1/vm-instances/bf2211ae8eaf408b817d3a05c19e2226/console-addresses

参数列表

名字类型位置描述可选值起始版本
uuidStringurl虚拟机UUID 0.6
systemTags (可选)Listquery系统标签 0.6
userTags (可选)Listquery用户标签 0.6

API返回

返回示例

{
  "hostIp": "192.168.10.100",
  "port": 5900,
  "protocol": "vnc",
  "vdiPortInfo": {
    "vncPort": 5900
  }
}
名字类型描述起始版本
hostIpString虚拟机运行主机IP0.6
portint虚拟机控制台端口0.6
protocolString虚拟机控制台协议,vnc或spice或vncAndSpice0.6
successboolean操作是否成功0.6
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。详情参考error0.6
vdiPortInfovdiPortInfo详情参考vdiPortInfo3.7.0

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

vdiPortInfo

名字类型描述起始版本
vncPortIntegervnc端口号3.7.0
spicePortIntegerspice端口号3.7.0
spiceTlsPortIntegerspice开启Tls加密,会存在spiceTlsPort和spicePort两个端口号,通过spice客户端连接虚拟机需要使用spiceTlsPort端口号3.7.0

SDK示例

Java SDK

GetVmConsoleAddressAction action = new GetVmConsoleAddressAction();
action.uuid = "d6bb8b652c1445969b5c4227385956d3";
action.sessionId = "1c0ec00749234a96978591d641e0c64d";
GetVmConsoleAddressAction.Result res = action.call();

Python SDK

GetVmConsoleAddressAction action = GetVmConsoleAddressAction()
action.uuid = "f6b7fe2da3ae4c929ad1c8ed14f37c8e"
action.sessionId = "5f127b3df90245ed93ef9da531442fdc"
GetVmConsoleAddressAction.Result res = action.call()