文档目录

控制台相关接口

请求控制台访问地址(RequestConsoleAccess)

API请求

URLs

POST zstack/v1/consoles

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "vmInstanceUuid": "b95acae48c804003ac3820751b58a50d"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vmInstanceUuid":"e0442db541833083bd7e411a4d94d969"}}' \
http://localhost:8080/zstack/v1/consoles

参数列表

名字 类型 位置 描述 可选值 起始版本
vmInstanceUuid String body(包含在params结构中) 云主机UUID 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例

{
  "inventory": {
    "scheme": "http",
    "hostname": "127.0.0.1",
    "port": 4900.0,
    "token": "d96caf24fae54c76b7652f548a258261"
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory ConsoleInventory 详情参考inventory 0.6

#error

名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

#inventory

名字 类型 描述 起始版本
scheme String 访问协议类型 0.6
hostname String 宿主机名称 0.6
port int 端口 0.6
token String 口令 0.6

SDK示例

Java SDK

RequestConsoleAccessAction action = new RequestConsoleAccessAction();
action.vmInstanceUuid = "c8925478e1f840caa1f3919affa19155";
action.sessionId = "f896abb919754292aa8d2f286596142c";
RequestConsoleAccessAction.Result res = action.call();

Python SDK

action = RequestConsoleAccessAction()
action.vmInstanceUuid = "f37c825f87444941bf16261f63c7dbb7"
action.sessionId = "331a21749df940e4b447e9103518890d"
res = action.call()

查询控制台代理(QueryConsoleProxyAgent)

API请求

URLs

GET zstack/v1/consoles/agents
GET zstack/v1/consoles/agents/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 350b72c2d3f24641a767acbcec744b19" \
-X GET http://localhost:8080/zstack/v1/consoles/agents?q=uuid=745b7c17cd224025b3adfef4ae61b3d2
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth bb08e240616b482984c397e4517a021c" \
-X GET http://localhost:8080/zstack/v1/consoles/agents/8a3cc2be7e20420db29925e381c598bc

可查询字段

运行CLI命令行工具,输入QueryConsoleProxyAgent并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例

{
  "inventories": [
    {
      "uuid": "c77bbc7d3364449e9543d0776a6087de",
      "managementIp": "127.0.0.1",
      "type": "ManagementServerConsoleProxy",
      "state": "Connected"
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventories List 详情参考inventories 0.6

#error

名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

#inventories

名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
description String 资源的详细描述 0.6
managementIp String 管理节点IP 0.6
type String 类型 0.6
status String 状态(连接,断开) 0.6
state String 状态(启用,禁用) 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6

SDK示例

Java SDK

QueryConsoleProxyAgentAction action = new QueryConsoleProxyAgentAction();
action.conditions = asList("uuid=dfbe49d87cb94d93b69354fa1270012b");
action.sessionId = "e2300cd4f74a457e87f13842aeb8fdef";
QueryConsoleProxyAgentAction.Result res = action.call();

Python SDK

action = QueryConsoleProxyAgentAction()
action.conditions = ["uuid=1e47046946f849ee871de20a2b045750"]
action.sessionId = "1655d7f2e56d4710824cd1082bd5cc94"
res = action.call()

重连控制台代理(ReconnectConsoleProxyAgent)

API请求

URLs

PUT zstack/v1/consoles/agents

Headers

Authorization: OAuth the-session-uuid

Body

{
  "reconnectConsoleProxyAgent": {
    "agentUuids": [
      "ce9f63639c6947fc9de43014a9c42af6",
      "5cf200f8fa6640278ab3751a9e40a122",
      "896f44bd3a2544e3b49a30dbe41303da"
    ]
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"reconnectConsoleProxyAgent":{"agentUuids":["9a00b78598253e68914541e6760ddeaa","c18fbd323fbd3902961e4105ec9364d0","96efd32908dd3f71bef8c0f414dbf828"]}}' \
http://localhost:8080/zstack/v1/consoles/agents

参数列表

名字 类型 位置 描述 可选值 起始版本
agentUuids (可选) List body(包含在params结构中) 控制台代理Agent的UUID 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例

{
  "inventory": {
    "976e8d54d42841da85eb697f3e8534b6": true,
    "ac4b5e3b69e5499eba381082199b5d42": true
  }
}
名字 类型 描述 起始版本
inventory Map 控制台代理Agent清单 0.6
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6

#error

名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK

ReconnectConsoleProxyAgentAction action = new ReconnectConsoleProxyAgentAction();
action.agentUuids = asList("9b1d2cae4e75418ba8ca00a7f8d61eee","b3c9068b99664b65851bc29e39c3e336","89ea316d7f114203bb352d22b1f878e2");
action.sessionId = "607aa9478e0f452ab3fe43f0bb44771f";
ReconnectConsoleProxyAgentAction.Result res = action.call();

Python SDK

action = ReconnectConsoleProxyAgentAction()
action.agentUuids = [6b5d95576b444661a23454913abce886, 64326c502c4042b196d9602737733d64, 1cc5a9dbb4284fbe850e387788b365ec]
action.sessionId = "dc7db7612de24cb7a3d91d1d08b03162"
res = action.call()

更新控制台代理(UpdateConsoleProxyAgent)

API请求

URLs

PUT zstack/v1/consoles/agents/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "updateConsoleProxyAgent": {
    "consoleProxyOverriddenIp": "127.0.0.1",
    "consoleProxyOverriddenIpv4": "127.0.0.1",
    "consoleProxyOverriddenIpv6": "2001:db8::100"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateConsoleProxyAgent":{"consoleProxyOverriddenIp":"127.0.0.1","consoleProxyOverriddenIpv4":"127.0.0.1","consoleProxyOverriddenIpv6":"2001:db8::100"}}' \
http://localhost:8080/zstack/v1/consoles/agents/f616460f24cd330180db4188c3a905b6/actions

参数列表

名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 2.3
consoleProxyOverriddenIp (可选) String body(包含在updateConsoleProxyAgent结构中) 新的控制台代理IP 2.3
consoleProxyOverriddenIpv4 (可选) String body(包含在updateConsoleProxyAgent结构中) 新的控制台代理IPv4地址 5.5.16
consoleProxyOverriddenIpv6 (可选) String body(包含在updateConsoleProxyAgent结构中) 新的控制台代理IPv6地址 5.5.16
systemTags (可选) List body 系统标签 2.3
userTags (可选) List body 用户标签 2.3

API返回

返回示例

{
  "inventory": {}
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 2.3
inventory ConsoleProxyAgentInventory 详情参考inventory 2.3

#error

名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

#inventory

名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
description String 资源的详细描述 0.6
managementIp String 管理节点IP 0.6
consoleProxyOverriddenIp String 控制台代理IP 2.3
consoleProxyOverriddenIpv4 String 控制台代理IPv4地址 5.5.16
consoleProxyOverriddenIpv6 String 控制台代理IPv6地址 5.5.16
consoleProxyPort Integer 控制台代理端口 4.1.0
type String 类型 0.6
status String 状态(连接,断开) 0.6
state String 状态(启用,禁用) 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6

SDK示例

Java SDK

UpdateConsoleProxyAgentAction action = new UpdateConsoleProxyAgentAction();
action.uuid = "f616460f24cd330180db4188c3a905b6";
action.consoleProxyOverriddenIp = "127.0.0.1";
action.consoleProxyOverriddenIpv4 = "127.0.0.1";
action.consoleProxyOverriddenIpv6 = "2001:db8::100";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateConsoleProxyAgentAction.Result res = action.call();

Python SDK

action = UpdateConsoleProxyAgentAction()
action.uuid = "f616460f24cd330180db4188c3a905b6"
action.consoleProxyOverriddenIp = "127.0.0.1"
action.consoleProxyOverriddenIpv4 = "127.0.0.1"
action.consoleProxyOverriddenIpv6 = "2001:db8::100"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()