文档目录

XStor Block主存储相关接口

添加Block主存储(AddBlockPrimaryStorage)

API请求

URLs

POST zstack/v1/primary-storage/block

Headers

Authorization: OAuth the-session-uuid

Body

{
  "param": {
    "vendorName": "XStor",
    "metadata": "{\u0027ip\u0027:\u0027127.0.0.1\u0027, \u0027port\u0027:8443, \u0027username\u0027:\u0027test\u0027, \u0027password\u0027:\u0027password\u0027}"
  },
  "systemTags": [],
  "userTags": []
}

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

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"param":{"vendorName":"XStor","metadata":"{'ip':'127.0.0.1', 'port':8443, 'username':'test', 'password':'password'}"}}' http://localhost:8080/zstack/v1/primary-storage/block

参数列表

名字 类型 位置 描述 可选值 起始版本
vendorName String body(包含在param结构中) 存储厂商名称 4.6.0
metadata String body(包含在param结构中) 存储的元数据 4.6.0
url String body(包含在param结构中) 未使用 4.6.0
name String body(包含在param结构中) Block主存储的名称 4.6.0
description (可选) String body(包含在param结构中) Block主存储的详细描述 4.6.0
type (可选) String body(包含在param结构中) 主存储的类型,此处为Block 4.6.0
zoneUuid String body(包含在param结构中) 区域UUID 4.6.0
resourceUuid (可选) String body(包含在param结构中) 资源UUID 4.6.0
tagUuids (可选) List body(包含在param结构中) 标签UUID列表 4.6.0
systemTags (可选) List body 系统标签 4.6.0
userTags (可选) List body 用户标签 4.6.0

API返回

返回示例

{
  "inventory": {
    "name": "PS1",
    "url": "/zstack_ps",
    "type": "LocalStorage",
    "state": "Enabled",
    "status": "Connected",
    "attachedClusterUuids": [
      "c6e9684e8bb93a9192c946dcd0564b39"
    ]
  }
}
名字 类型 描述 起始版本
success boolean 4.6.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.6.0
inventory PrimaryStorageInventory 详情参考inventory 4.6.0

#error

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

#inventory

名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.6.0
zoneUuid String 区域UUID 4.6.0
name String 资源名称 4.6.0
url String 4.6.0
description String 资源的详细描述 4.6.0
totalCapacity Long 总空间 4.6.0
availableCapacity Long 可用空间 4.6.0
totalPhysicalCapacity Long 总物理空间 4.6.0
availablePhysicalCapacity Long 物理可用空间 4.6.0
systemUsedCapacity Long 系统使用空间 4.6.0
type String 主存储类型 4.6.0
state String 启用状态 4.6.0
status String 连接状态 4.6.0
mountPath String 4.6.0
createDate Timestamp 创建时间 4.6.0
lastOpDate Timestamp 最后一次修改时间 4.6.0
attachedClusterUuids List 挂载的集群 4.6.0

SDK示例

Java SDK

AddBlockPrimaryStorageAction action = new AddBlockPrimaryStorageAction();
action.vendorName = "XStor";
action.metadata = "{'ip':'127.0.0.1', 'port':8443, 'username':'test', 'password':'password'}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddBlockPrimaryStorageAction.Result res = action.call();

Python SDK

action = AddBlockPrimaryStorageAction()
action.vendorName = "XStor"
action.metadata = "{'ip':'127.0.0.1', 'port':8443, 'username':'test', 'password':'password'}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

获取Block存储的元数据(GetBlockPrimaryStorageMetadata)

API请求

URLs

POST zstack/v1/primary-storage/block/metadata

Headers

Authorization: OAuth the-session-uuid

Body

{
  "param": {
    "vendorName": "XStor",
    "metadata": "{\u0027ip\u0027:\u0027127.0.0.1\u0027,\u0027port\u0027:8443,\u0027username\u0027:\u0027test\u0027,\u0027password\u0027:\u0027123\u0027}"
  },
  "systemTags": [],
  "userTags": []
}

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

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"param":{"vendorName":"XStor","metadata":"{'ip':'127.0.0.1','port':8443,'username':'test','password':'123'}"}}' http://localhost:8080/zstack/v1/primary-storage/block/metadata

参数列表

名字 类型 位置 描述 可选值 起始版本
vendorName String body(包含在param结构中) Block存储厂商名称 4.6.0
metadata String body(包含在param结构中) 存储元数据(ip,port,用户名、密码) 4.6.0
systemTags (可选) List body 系统标签 4.6.0
userTags (可选) List body 用户标签 4.6.0

API返回

返回示例

{
  "inventories": [
    {
      "vendorName": "XStor",
      "uuid": "8f93d463f7d73e1c959aee815ff1e9a8"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 4.6.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.6.0
inventory PrimaryStorageInventory 详情参考inventory 4.6.0

#error

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

#inventory

名字 类型 描述 起始版本
vendorName String 存储厂商名称 4.6.0
metadata String 存储元数据 4.6.0
uuid String 资源的UUID,唯一标示该资源 4.6.0
zoneUuid String 区域UUID 4.6.0
name String 主存储名称 4.6.0
url String 未使用 4.6.0
description String 资源的详细描述 4.6.0
totalCapacity Long 总空间 4.6.0
availableCapacity Long 可用空间 4.6.0
totalPhysicalCapacity Long 总物理空间 4.6.0
availablePhysicalCapacity Long 物理可用空间 4.6.0
systemUsedCapacity Long 系统使用空间 4.6.0
type String 主存储类型 4.6.0
state String 启用状态 4.6.0
status String 连接状态 4.6.0
mountPath String 未使用 4.6.0
createDate Timestamp 创建时间 4.6.0
lastOpDate Timestamp 最后一次修改时间 4.6.0
attachedClusterUuids List 挂载的集群 4.6.0

SDK示例

Java SDK

GetBlockPrimaryStorageMetadataAction action = new GetBlockPrimaryStorageMetadataAction();
action.vendorName = "XStor";
action.metadata = "{'ip':'127.0.0.1','port':8443,'username':'test','password':'123'}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetBlockPrimaryStorageMetadataAction.Result res = action.call();

Python SDK

action = GetBlockPrimaryStorageMetadataAction()
action.vendorName = "XStor"
action.metadata = "{'ip':'127.0.0.1','port':8443,'username':'test','password':'123'}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

查询Block主存储(QueryBlockPrimaryStorage)

API请求

URLs

GET zstack/v1/primary-storage/block
GET zstack/v1/primary-storage/block/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/primary-storage/block
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/primary-storage/block/27520555d8e2373e9a7ec3801e358e1c

可查询字段

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

API返回

返回示例

{
  "inventories": [
    {
      "vendorName": "XStor",
      "uuid": "8f93d463f7d73e1c959aee815ff1e9a8"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 4.6.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.6.0
inventory PrimaryStorageInventory 详情参考inventories 4.6.0

#error

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

#inventories

名字 类型 描述 起始版本
vendorName String 存储厂商名称 4.6.0
metadata String 存储元数据 4.6.0
uuid String 资源的UUID,唯一标示该资源 4.6.0
zoneUuid String 区域UUID 4.6.0
name String 主存储名称 4.6.0
url String 未使用 4.6.0
description String 资源的详细描述 4.6.0
totalCapacity Long 总空间 4.6.0
availableCapacity Long 可用空间 4.6.0
totalPhysicalCapacity Long 总物理空间 4.6.0
availablePhysicalCapacity Long 物理可用空间 4.6.0
systemUsedCapacity Long 系统使用空间 4.6.0
type String 主存储类型 4.6.0
state String 启用状态 4.6.0
status String 连接状态 4.6.0
mountPath String 未使用 4.6.0
createDate Timestamp 创建时间 4.6.0
lastOpDate Timestamp 最后一次修改时间 4.6.0
attachedClusterUuids List 挂载的集群 4.6.0

SDK示例

Java SDK

QueryBlockPrimaryStorageAction action = new QueryBlockPrimaryStorageAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryBlockPrimaryStorageAction.Result res = action.call();

Python SDK

action = QueryBlockPrimaryStorageAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

更新Block主存储(UpdateBlockPrimaryStorage)

API请求

URLs

PUT zstack/v1/primary-storage/block/{uuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "updateBlockPrimaryStorage": {
    "vendorName": "XStor",
    "metadata": "{\u0027ip\u0027:\u0027127.0.0.1\u0027, \u0027port\u0027:8443, \u0027user\u0027:\u0027test\u0027, \u0027password\u0027:\u0027password\u0027}"
  },
  "systemTags": [],
  "userTags": []
}}

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

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateBlockPrimaryStorage":{"vendorName":"XStor","metadata":"{'ip':'127.0.0.1', 'port':8443, 'user':'test', 'password':'password'}"}}' \
http://localhost:8080/zstack/v1/primary-storage/block/blockPrimarySttorageUuid/actions

参数列表

名字 类型 位置 描述 可选值 起始版本
vendorName(可选) String body(包含在param结构中) Block存储厂商名称 4.8.0
metadata(可选) String body(包含在param结构中) 存储元数据(ip,port,用户名、密码) 4.8..0
uuid String url 资源的UUID,唯一标示该资源 4.8.0
systemTags (可选) List body 系统标签 4.8.0
userTags (可选) List body 用户标签 4.8..0

API返回

返回示例

{
  "inventory": {
    "vendorName": "XStor",
    "metadata": "{\u0027ip\u0027:\u0027127.0.0.1\u0027, \u0027port\u0027:8443, \u0027user\u0027:\u0027test\u0027, \u0027password\u0027:\u0027password\u0027}",
    "uuid": "c85e957b4b4b3f949494275d443c9807",
    "name": "block primary storage",
    "description": "block primary storage description",
    "availableCapacity": 1073741824,
    "availablePhysicalCapacity": 1073741824,
    "type": "BlockStorage",
    "state": "Enabled",
    "status": "Connected",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
名字 类型 描述 起始版本
success boolean 4.8.0
inventory BlockPrimaryStorageInventory 详情参考inventories 4.8.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.8.0

#inventories

名字 类型 描述 起始版本
vendorName String 存储厂商名称 4.8.0
metadata String 存储元数据 4.8.0
uuid String 资源的UUID,唯一标示该资源 4.8.0
zoneUuid String 区域UUID 4.8.0
name String 主存储名称 4.8.0
url String 未使用 4.8.0
description String 资源的详细描述 4.8.0
totalCapacity Long 总空间 4.8.0
availableCapacity Long 可用空间 4.8.0
totalPhysicalCapacity Long 总物理空间 4.8.0
availablePhysicalCapacity Long 物理可用空间 4.8.0
systemUsedCapacity Long 系统使用空间 4.8.0
type String 主存储类型 4.8.0
state String 启用状态 4.8.0
status String 连接状态 4.8.0
mountPath String 未使用 4.8.0
createDate Timestamp 创建时间 4.8.0
lastOpDate Timestamp 最后一次修改时间 4.8.0
attachedClusterUuids List 挂载的集群 4.8.0

#error

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

SDK示例

Java SDK

UpdateBlockPrimaryStorageAction action = new UpdateBlockPrimaryStorageAction();
action.vendorName = "XStor";
action.metadata = "{'ip':'127.0.0.1', 'port':8443, 'user':'test', 'password':'password'}";
action.uuid = "blockPrimarySttorageUuid";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateBlockPrimaryStorageAction.Result res = action.call();

Python SDK

action = UpdateBlockPrimaryStorageAction()
action.vendorName = "XStor"
action.metadata = "{'ip':'127.0.0.1', 'port':8443, 'user':'test', 'password':'password'}"
action.uuid = "blockPrimarySttorageUuid"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()