查询集群

GET/zstack/v1/clusters
GET/zstack/v1/clusters/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 815c808ecfb5461b953544d4bcefea31" \
-X GET http://localhost:8080/zstack/v1/clusters?q=hypervisorType=KVM
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 663eef55906d4b6e9750f9b4ed65f5f9" \
-X GET http://localhost:8080/zstack/v1/clusters/a8d5ea1ceda34616a26bec2fce3b4d8a

可查询字段

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

API返回

返回示例

{
  "inventories": [
    {
      "name": "cluster1",
      "uuid": "41f3a4eb130347a2af6d7f2e0d21fab0",
      "description": "test",
      "state": "Enabled",
      "hypervisorType": "KVM",
      "createDate": "Jun 7, 2017 9:20:13 PM",
      "lastOpDate": "Jun 7, 2017 9:20:13 PM",
      "zoneUuid": "aad01c8b25774796b2e341ec51a7c9c1",
      "type": "zstack"
    }
  ]
}
名字类型描述起始版本
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error0.6
inventoriesList详情参考inventories0.6

error

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

inventories

名字类型描述起始版本
nameString资源名称0.6
uuidString资源的UUID,唯一标示该资源0.6
descriptionString资源的详细描述0.6
stateString集群状态0.6
hypervisorTypeString虚拟机管理程序类型0.6
createDateTimestamp创建时间0.6
lastOpDateTimestamp最后一次修改时间0.6
zoneUuidString数据中心UUID0.6
typeString保留域0.6

SDK示例

Java SDK

QueryClusterAction action = new QueryClusterAction();
action.conditions = asList("hypervisorType=KVM");
action.sessionId = "3e214b652cc947ea9e1aa256d05752ea";
QueryClusterAction.Result res = action.call();

Python SDK

QueryClusterAction action = QueryClusterAction()
action.conditions = ["hypervisorType=KVM"]
action.sessionId = "ad8f3cd4b5bc4da0a3a91dc8bcbdd18c"
QueryClusterAction.Result res = action.call()