获取目的地列表(GetCandidateZonesClustersHostsForCreatingVm)
获取可以创建指定云主机参数的目的区域、集群、物理机。用户可以使用该API,通过指定云主机参数获得可以创建满足参数云主机的目的地。
API请求
URLs
GET zstack/v1/vm-instances/candidate-destinationsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"instanceOfferingUuid": "74dfdb443272486cad0e1136d982d0eb",
"imageUuid": "446ca20ccd5e420fa383df8fab965caa",
"l3NetworkUuids": [
"654722ff8884499a8723010ef41bbb9b"
],
"dataDiskOfferingUuids": [
"3ab2044725594ed7ba7466b710bf99b5",
"a1a0cbbc8d704318841f707aa3c7c219"
],
"clusterUuid": "f614e3dad723466c9ddd9190ef69fe62"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \
-H "Authorization: OAuth bcbb6fa236704f2ca1742db90a41c6b9" \
-X GET http://localhost:8080/zstack/v1/vm-instances/candidate-destinations?\
instanceOfferingUuid=ef41e6e0659140deae7beb9e48d09b9d&imageUuid=93ca46ed00ac4fa0a5e6dc497a8b3e4b\
&l3NetworkUuids=9dc450a21d5745cca0f586c7f1fc955f\
&dataDiskOfferingUuids=66bbcf29e2ca4564a158113459d23208\
&dataDiskOfferingUuids=fc7fed0cba394e2cb660b10ded193ac1&clusterUuid=db6cc0784cf64f4a8cf47d23d8c2802a参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版 |
|---|---|---|---|---|---|
| instanceOfferingUuid | String | query | 计算规格UUID | 0.6 | |
| imageUuid | String | query | 镜像UUID | 0.6 | |
| l3NetworkUuids | List | query | 三层网络列表 | 0.6 | |
| rootDiskOfferingUuid (可选) | String | query | 根云盘规格。仅在imageUuid指定的镜像是ISO时需要指定 | 0.6 | |
| dataDiskOfferingUuids (可选) | List | query | 云盘规格列表 | 0.6 | |
| zoneUuid (可选) | String | query | 区域UUID | 0.6 | |
| clusterUuid (可选) | String | query | 集群UUID | 0.6 | |
| defaultL3NetworkUuid (可选) | String | query | 默认三层网络UUID | 0.6 | |
| systemTags (可选) | List | query | 系统标签 | 0.6 | |
| userTags (可选) | List | query | 用户标签 | 0.6 |
API返回
返回示例
{
"zones": [
{
"uuid": "b145bc2ad8f14810a6eec0f28508ca14",
"name": "zone"
}
],
"clusters": [
{
"name": "cluster1",
"uuid": "49adbf0f48a14b899b0e6f7928556313",
"hypervisorType": "KVM",
"createDate": "May 11, 2017 1:23:06 PM",
"lastOpDate": "May 11, 2017 1:23:06 PM",
"zoneUuid": "b68fec24ba0f492c94c2e046072c16f0"
}
],
"hosts": [
{
"zoneUuid": "b145bc2ad8f14810a6eec0f28508ca14",
"name": "example",
"uuid": "e1a5cb10bcbc48b4ab6dd4e648ef5960",
"clusterUuid": "d5b32ea0ae1444d3b8b5a6b9d759af54",
"description": "example",
"managementIp": "192.168.0.1",
"hypervisorType": "KVM",
"state": "Enabled",
"status": "Connected",
"totalCpuCapacity": 4.0,
"availableCpuCapacity": 2.0,
"totalMemoryCapacity": 4.0,
"availableMemoryCapacity": 4.0,
"createDate": "May 11, 2017 1:23:06 PM",
"lastOpDate": "May 11, 2017 1:23:06 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 操作是否成功 | 0.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| zones | List | 详情参考zones | 0.6 |
| clusters | List | 详情参考clusters | 0.6 |
| hosts | List | 详情参考hosts | 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 |
#zones
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| state | String | 0.6 | |
| type | String | 0.6 | |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
#clusters
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| state | String | 集群状态 | 0.6 |
| hypervisorType | String | 虚拟机管理程序类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| zoneUuid | String | 区域UUID | 0.6 |
| type | String | 保留域 | 0.6 |
#hosts
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| zoneUuid | String | 区域UUID | 0.6 |
| name | String | 资源名称 | 0.6 |
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| clusterUuid | String | 集群UUID | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| managementIp | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| state | String | 0.6 | |
| status | String | 0.6 | |
| totalCpuCapacity | Long | 0.6 | |
| availableCpuCapacity | Long | 0.6 | |
| cpuSockets | Integer | 0.6 | |
| totalMemoryCapacity | Long | 0.6 | |
| availableMemoryCapacity | Long | 0.6 | |
| cpuNum | Integer | 0.6 | |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
SDK示例
Java
SDK
GetCandidateZonesClustersHostsForCreatingVmAction action = new GetCandidateZonesClustersHostsForCreatingVmAction();
action.instanceOfferingUuid = "f1569e619ba44cfeb264759df0720b19";
action.imageUuid = "57374e8324c34999ba81bd363a576653";
action.l3NetworkUuids = asList("dfac2b50c85a498780cf6d1828075e51");
action.dataDiskOfferingUuids = asList("bbe0af9d301e44d6b4605c6ed61f33d5","49f0cbfd2b694e5f9a5cf631f7dc219b");
action.clusterUuid = "0efc966199184f99982e9874186aab38";
action.sessionId = "5d04a0ac859746dea2f9cd81329e91ea";
GetCandidateZonesClustersHostsForCreatingVmAction.Result res = action.call();Python
SDK
GetCandidateZonesClustersHostsForCreatingVmAction action = GetCandidateZonesClustersHostsForCreatingVmAction()
action.instanceOfferingUuid = "6aef4e5bcf944af293096558effda40d"
action.imageUuid = "8a93ad62da8c436e8b79f37aae134bc6"
action.l3NetworkUuids = [3f1df9b106a04503bb1c7a68c7bddf75]
action.dataDiskOfferingUuids = [71817f0e5fa04e4e8ef5c035a0f84e67, ddb83b57bfc14aadb3df1ca6d40bfe04]
action.clusterUuid = "c910b625c0f94958a6a7e4ad3df15d34"
action.sessionId = "ae4cc6df99b14fb091a9b3779228709c"
GetCandidateZonesClustersHostsForCreatingVmAction.Result res = action.call()