云盘规格相关接口
创建云盘规格(CreateDiskOffering)
API请求
URLs
POST zstack/v1/disk-offeringsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "diskOffering1",
"diskSize": 100.0,
"sortKey": 0.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"diskOffering1","diskSize":100.0,"sortKey":0.0}}' \
http://localhost:8080/zstack/v1/disk-offerings参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 0.6 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 0.6 | |
| diskSize | long | body(包含在params结构中) | 云盘大小 | 0.6 | |
| sortKey (可选) | int | body(包含在params结构中) | 排序key | 0.6 | |
| allocationStrategy (可选) | String | body(包含在params结构中) | 分配策略 |
|
4.6.21 |
| type (可选) | String | body(包含在params结构中) | 类型 | 0.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
Note:
- ZStack Cloud创建云盘规格时支持自定义云盘规格参数,SystemTags增加diskOfferingUserConfig选项。
- 选项格式为:
diskOfferingUserConfig::xxx,XXX要求JSON字符串。例如,为云盘规格指定多个主存储:diskOfferingUserConfig::{ "allocate": { "primaryStorages":[ { "type":"输入主存储类型", "uuid":"输入主存储UUID" }, { "type":"输入主存储类型", "uuid":"输入主存储UUID" }, { "type":"输入主存储类型", "uuid":"输入主存储UUID" } ] } }
- 选项格式为:
API返回
返回示例
{
"inventory": {
"uuid": "e7a865815cd34dd29812d335dc1019bf",
"name": "diskOffering1",
"diskSize": 100.0,
"state": "Enabled",
"type": "DefaultDiskOfferingType",
"allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | DiskOfferingInventory | 详情参考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
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| diskSize | Long | 云盘大小 | 0.6 |
| sortKey | Integer | 0.6 | |
| state | String | 状态(启动,禁用) | 0.6 |
| type | String | 类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| allocatorStrategy | String | 分配策略 | 0.6 |
SDK示例
Java
SDK
CreateDiskOfferingAction action = new CreateDiskOfferingAction();
action.name = "diskOffering1";
action.diskSize = 100.0;
action.sortKey = 0.0;
action.sessionId = "5c780b5178c0432b9f86a758c4c75ea1";
CreateDiskOfferingAction.Result res = action.call();Python
SDK
CreateDiskOfferingAction action = CreateDiskOfferingAction()
action.name = "diskOffering1"
action.diskSize = 100.0
action.sortKey = 0.0
action.sessionId = "f930e0f78ce948778c8c3f1cbcd0c4ec"
CreateDiskOfferingAction.Result res = action.call()删除云盘规格(DeleteDiskOffering)
API请求
URLs
DELETE/v1/disk-offerings/{uuid}?deleteMode={deleteMode}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth e12cbd12fbd54afd96c463c093ce1ed9" \
-X DELETE http://localhost:8080/zstack/v1/disk-offerings/6313fb03124a4aa6b7f77d8d153c0bcb?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| deleteMode (可选) | String | body | 删除模式 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteDiskOfferingAction action = new DeleteDiskOfferingAction();
action.uuid = "1d4e09f16c7c45abaab80be172b26cc1";
action.deleteMode = "Permissive";
action.sessionId = "1a31abeeef7e4ab5bc538168be6deb05";
DeleteDiskOfferingAction.Result res = action.call();Python
SDK
DeleteDiskOfferingAction action = DeleteDiskOfferingAction()
action.uuid = "4f0d2dc3a8f34685ad8543834bf4cfd8"
action.deleteMode = "Permissive"
action.sessionId = "dce93830769b427ca6edf3bda25f65f6"
DeleteDiskOfferingAction.Result res = action.call()查询云盘规格(QueryDiskOffering)
API请求
URLs
GET zstack/v1/disk-offerings
GET zstack/v1/disk-offerings/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth d6550daa638547498b8075f3ebd1e240" \
-X GET http://localhost:8080/zstack/v1/disk-offerings?q=uuid=85c065f24d024bf3920766692da392ebcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 3b32284bc5344692a8bc77a43610f460" \
-X GET http://localhost:8080/zstack/v1/disk-offerings/2f25294896e24c89b63edb7a209ebb85
可查询字段
运行CLI命令行工具,输入QueryDiskOffering并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "7bd03741125a48d485255601b639318b",
"name": "diskOffering1",
"diskSize": 100.0,
"state": "Enabled",
"type": "DefaultDiskOfferingType",
"allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| 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 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| diskSize | Long | 云盘大小 | 0.6 |
| sortKey | Integer | 0.6 | |
| state | String | 状态(启动,禁用) | 0.6 |
| type | String | 类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| allocatorStrategy | String | 分配策略 | 0.6 |
SDK示例
Java
SDK
QueryDiskOfferingAction action = new QueryDiskOfferingAction();
action.conditions = asList("uuid=e01b8a266d05425ba2d0c05308763db8");
action.sessionId = "d8a3f3b62d8c4affab7c5d491f95d4de";
QueryDiskOfferingAction.Result res = action.call();Python
SDK
QueryDiskOfferingAction action = QueryDiskOfferingAction()
action.conditions = ["uuid=a1f7f68522e64783a37095a862f9bc28"]
action.sessionId = "593740538236497183e065e1251b6937"
QueryDiskOfferingAction.Result res = action.call()更改云盘规格的启用状态(ChangeDiskOfferingState)
API请求
URLs
PUT zstack/v1/disk-offerings/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeDiskOfferingState": {
"stateEvent": "enable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeDiskOfferingState":{"stateEvent":"enable"}}' \
http://localhost:8080/zstack/v1/disk-offerings/39c32ae614e23ce2a6877797a09037fd/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| stateEvent | String | body(包含在changeDiskOfferingState结构中) | 状态事件 |
|
0.6 |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "5e84d8a44b2941eb96d9eec31e0524be",
"name": "diskOffering1",
"diskSize": 100.0,
"state": "Enabled",
"type": "DefaultDiskOfferingType",
"allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | DiskOfferingInventory | 详情参考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
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| diskSize | Long | 云盘大小 | 0.6 |
| sortKey | Integer | 0.6 | |
| state | String | 状态(启动,禁用) | 0.6 |
| type | String | 类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| allocatorStrategy | String | 分配策略 | 0.6 |
SDK示例
Java
SDK
ChangeDiskOfferingStateAction action = new ChangeDiskOfferingStateAction();
action.uuid = "b99744228d4943959881b051cecb376d";
action.stateEvent = "enable";
action.sessionId = "8733eb947ada42bb8769ad170f889e98";
ChangeDiskOfferingStateAction.Result res = action.call();Python
SDK
ChangeDiskOfferingStateAction action = ChangeDiskOfferingStateAction()
action.uuid = "521d538a214c42e39d16cef5a1e13cc9"
action.stateEvent = "enable"
action.sessionId = "7e7ba75914814242a268026ca77163e5"
ChangeDiskOfferingStateAction.Result res = action.call()更新云盘规格(UpdateDiskOffering)
API请求
URLs
PUT zstack/v1/disk-offerings/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateDiskOffering": {
"name": "new name"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateDiskOffering":{"name":"new name"}}' \
http://localhost:8080/zstack/v1/disk-offerings/1a2b9698ee163ad69374f765f6234f02/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| name (可选) | String | body(包含在updateDiskOffering结构中) | 资源名称 | 0.6 | |
| description (可选) | String | body(包含在updateDiskOffering结构中) | 资源的详细描述 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "a156bb54daa544628f2abff419c76977",
"name": "new name",
"diskSize": 100.0,
"state": "Enabled",
"type": "DefaultDiskOfferingType",
"allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | DiskOfferingInventory | 详情参考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
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| diskSize | Long | 云盘大小 | 0.6 |
| sortKey | Integer | 0.6 | |
| state | String | 状态(启动,禁用) | 0.6 |
| type | String | 类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| allocatorStrategy | String | 分配策略 | 0.6 |
SDK示例
Java
SDK
UpdateDiskOfferingAction action = new UpdateDiskOfferingAction();
action.uuid = "21226fe14a8042d2ad1d37640c8a8594";
action.name = "new name";
action.sessionId = "c8e71fd622614f15b3452a8fa451d037";
UpdateDiskOfferingAction.Result res = action.call();Python
SDK
UpdateDiskOfferingAction action = UpdateDiskOfferingAction()
action.uuid = "30d4acc261f34c55a297a203fed852e2"
action.name = "new name"
action.sessionId = "0236ee9dd5d440de84f867e9d550172c"
UpdateDiskOfferingAction.Result res = action.call()