获取USB透传候选列表(GetUsbDeviceCandidatesForAttachingVm)
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/candidate-usb-devicesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/ab759c79169739cb9e13ff091c4fa386/candidate-usb-devices?attachType=PassThrough参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | 云主机UUID | 2.2 | |
| attachType (可选) | String | query | 加载类型 |
|
3.6.0 |
| systemTags (可选) | List | query | 系统标签 | 2.2 | |
| userTags (可选) | List | query | 用户标签 | 2.2 |
API返回
返回示例
{
"inventories": [
{
"uuid": "b58b4b48b3b8398f93b8b529f6f5b53a",
"name": "usb",
"hostUuid": "9f7438cf6fd233cf8fc27d4f311326ca",
"vmInstanceUuid": "ccdfb1d443433e1a8beac3a1d54374d5",
"state": "Enabled",
"busNum": "001",
"devNum": "001",
"idVendor": "0781",
"idProduct": "5591",
"iManufacturer": "SanDisk",
"iProduct": "Ultra USB 3.0",
"iSerial": "000000000001",
"usbVersion": "3.0",
"attachType": "PassThrough"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 成功 | 2.2 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.2 |
| inventories | List | 详情参考inventories | 2.2 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.2 |
| description | String | 错误的概要描述 | 2.2 |
| details | String | 错误的详细信息 | 2.2 |
| elaboration | String | 保留字段,默认为null | 2.2 |
| opaque | LinkedHashMap | 保留字段,默认为null | 2.2 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.2 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 2.2 |
| name | String | 资源名称 | 2.2 |
| description | String | 资源的详细描述 | 2.2 |
| hostUuid | String | 物理机UUID | 2.2 |
| vmInstanceUuid | String | 云主机UUID | 2.2 |
| busNum | String | 总线号 | 2.2 |
| devNum | String | 设备号 | 2.2 |
| idVendor | String | VendorID | 2.2 |
| idProduct | String | ProductID | 2.2 |
| iManufacturer | String | 生产商 | 2.2 |
| iProduct | String | 设备类型 | 2.2 |
| iSerial | String | 序列号 | 2.2 |
| usbVersion | String | USB版本 | 2.2 |
| attachType | String | 加载方式 | 3.5.0 |
| createDate | Timestamp | 创建时间 | 2.2 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.2 |
| state | UsbDeviceState | 详情参考state | 2.2 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 2.2 |
| ordinal | int | 2.2 |
SDK示例
Java
SDK
GetUsbDeviceCandidatesForAttachingVmAction action = new GetUsbDeviceCandidatesForAttachingVmAction();
action.vmInstanceUuid = "ab759c79169739cb9e13ff091c4fa386";
action.attachType = "PassThrough";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetUsbDeviceCandidatesForAttachingVmAction.Result res = action.call();Python
SDK
GetUsbDeviceCandidatesForAttachingVmAction action = GetUsbDeviceCandidatesForAttachingVmAction()
action.vmInstanceUuid = "ab759c79169739cb9e13ff091c4fa386"
action.attachType = "PassThrough"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetUsbDeviceCandidatesForAttachingVmAction.Result res = action.call()