SR-IOV相关接口
分布式端口组中是否存在可用VF网卡(IsVfNicAvailableInL3Network)
API请求
URLs
GET zstack/v1/l3-networks/{l3NetworkUuid}/hosts/{hostUuid}/vfnicavailableHeaders
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/l3-networks/443e156ec6883356974f97f803187310/hosts/037404d26b033e9d9fe0d3e7e4bbaa8b/vfnicavailable参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| l3NetworkUuid | String | url | 分布式端口组UUID | 3.9.0 | |
| hostUuid | String | url | 主机UUID | 3.9.0 | |
| systemTags (可选) | List | query | 系统标签 | 3.9.0 | |
| userTags (可选) | List | query | 用户标签 | 3.9.0 |
API返回
返回示例
{
"vfNicAvailable": true
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| vfNicAvailable | boolean | 是否存在可用VF网卡 | 3.9.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
SDK示例
Java
SDK
IsVfNicAvailableInL3NetworkAction action = new IsVfNicAvailableInL3NetworkAction();
action.l3NetworkUuid = "443e156ec6883356974f97f803187310";
action.hostUuid = "037404d26b033e9d9fe0d3e7e4bbaa8b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
IsVfNicAvailableInL3NetworkAction.Result res = action.call();Python
SDK
IsVfNicAvailableInL3NetworkAction action = IsVfNicAvailableInL3NetworkAction()
action.l3NetworkUuid = "443e156ec6883356974f97f803187310"
action.hostUuid = "037404d26b033e9d9fe0d3e7e4bbaa8b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
IsVfNicAvailableInL3NetworkAction.Result res = action.call()修改虚拟机网卡类型(ChangeVmNicType)
API请求
URLs
PUT zstack/v1/vm-instances/nics/{vmNicUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeVmNicType": {
"vmNicType": "VNIC"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeVmNicType":{"vmNicType":"VNIC"}}' \
http://localhost:8080/zstack/v1/vm-instances/nics/ba83aa15bafd33e792267c428465b1e5/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmNicUuid | String | url | 虚拟机网卡UUID | 3.9.0 | |
| vmNicType | String | body(包含在changeVmNicType结构中) | 虚拟机网卡类型 |
|
3.9.0 |
| systemTags (可选) | List | body | 系统标签 | 3.9.0 | |
| userTags (可选) | List | body | 用户标签 | 3.9.0 |
API返回
返回示例
{
"inventory": {
"uuid": "bd44ea50e2573d5d9249c938dba0dad6",
"vmInstanceUuid": "1311eba1f7e53c3aa816a140fd783068",
"usedIpUuid": "464575b453d53e60941c7eeee08f3149",
"l3NetworkUuid": "b62214c53fde3f6eb825bf2ce59e3d2e",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0.0,
"type": "VF"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
| inventory | VmNicInventory | 详情参考inventory | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.9.0 |
| vmInstanceUuid | String | 虚拟机UUID | 3.9.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 3.9.0 |
| ip | String | IP地址 | 3.9.0 |
| mac | String | MAC地址 | 3.9.0 |
| hypervisorType | String | 虚拟化类型 | 3.9.0 |
| netmask | String | 子网掩码 | 3.9.0 |
| gateway | String | 网关 | 3.9.0 |
| metaData | String | 3.9.0 | |
| ipVersion | Integer | IP地址版本 | 3.9.0 |
| driverType | String | 3.17.13 | |
| internalName | String | 3.17.13 | |
| deviceId | Integer | 设备ID | 3.9.0 |
| type | String | 网卡类型 | 3.9.0 |
| state | String | 网卡状态 | 3.17.13 |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
| usedIps | List | 详情参考usedIps | 3.9.0 |
#usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.9.0 |
| ipRangeUuid | String | IP段UUID | 3.9.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 3.9.0 |
| ipVersion | Integer | IP协议号 | 3.9.0 |
| ip | String | IP地址 | 3.9.0 |
| netmask | String | 网络掩码 | 3.9.0 |
| gateway | String | 网关地址 | 3.9.0 |
| usedFor | String | 3.9.0 | |
| ipInLong | long | 3.9.0 | |
| vmNicUuid | String | 虚拟机网卡UUID | 3.9.0 |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
SDK示例
Java SDK
ChangeVmNicTypeAction action = new ChangeVmNicTypeAction();
action.vmNicUuid = "ba83aa15bafd33e792267c428465b1e5";
action.vmNicType = "VNIC";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmNicTypeAction.Result res = action.call();Python SDK
action = ChangeVmNicTypeAction()
action.vmNicUuid = "ba83aa15bafd33e792267c428465b1e5"
action.vmNicType = "VNIC"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询VF网卡(QueryEthernetVF)
API请求
URLs
GET zstack/v1/pci-device/ethernet-vfs
GET zstack/v1/pci-device/ethernet-vfs/{uuid}Headers
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/pci-device/ethernet-vfscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/pci-device/ethernet-vfs/bd26758dc3713723bfcd652b8c714e1e可查询字段
运行CLI命令行工具,输入QueryEthernetVF并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"interfaceName": "eth0",
"vfStatus": "Available",
"hostUuid": "e21879b9f8c63800a211852d183d6650",
"parentUuid": "da87312aa5ab3ddbb05c61a3564bc5e4",
"type": "Ethernet_Controller",
"vendorId": "10de",
"deviceId": "0e0f",
"subvendorId": "10de",
"subdeviceId": "118b",
"pciDeviceAddress": "0000:06:00.1"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.2.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.2.0 |
| inventories | List | 详情参考inventories | 4.2.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.2.0 |
| description | String | 错误的概要描述 | 4.2.0 |
| details | String | 错误的详细信息 | 4.2.0 |
| elaboration | String | 保留字段,默认为null | 4.2.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.2.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.2.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| hostDevUuid | String | 主机Uuid | 4.2.0 |
| interfaceName | String | 物理网卡名称 | 4.2.0 |
| vmUuid | String | 虚拟机Uuid | 4.2.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.2.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 4.2.0 |
| name | String | 资源名称 | 4.2.0 |
| description | String | 资源的详细描述 | 4.2.0 |
| hostUuid | String | 主机UUID | 4.2.0 |
| parentUuid | String | 4.2.0 | |
| vmInstanceUuid | String | 虚拟机UUID | 4.2.0 |
| pciSpecUuid | String | 4.2.0 | |
| vendorId | String | 4.2.0 | |
| deviceId | String | 4.2.0 | |
| subvendorId | String | 4.2.0 | |
| subdeviceId | String | 4.2.0 | |
| pciDeviceAddress | String | 4.2.0 | |
| iommuGroup | String | 4.2.0 | |
| createDate | Timestamp | 创建时间 | 4.2.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.2.0 |
| vfStatus | EthernetVfStatus | 详情参考vfStatus | 4.2.0 |
| type | PciDeviceType | 详情参考type | 4.2.0 |
| state | PciDeviceState | 详情参考state | 4.2.0 |
| status | PciDeviceStatus | 详情参考status | 4.2.0 |
| virtStatus | PciDeviceVirtStatus | 详情参考virtStatus | 4.2.0 |
| chooser | PciDeviceChooser | 详情参考chooser | 4.2.0 |
| metaData | PciDeviceMetaData | 详情参考metaData | 4.2.0 |
| matchedPciDeviceOfferingRef | List | 详情参考matchedPciDeviceOfferingRef | 4.2.0 |
| mdevSpecRefs | List | 详情参考mdevSpecRefs | 4.2.0 |
#vfStatus
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Available | EthernetVfStatus | 可用 | 4.2.0 |
| Reserved | EthernetVfStatus | 预分配 | 4.2.0 |
| Attached | EthernetVfStatus | 已使用 | 4.2.0 |
| Releasing | EthernetVfStatus | 释放中 | 4.2.0 |
#type
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| GPU_Video_Controller | PciDeviceType | GPU显卡控制器 | 2.1 |
| GPU_Audio_Controller | PciDeviceType | GPU声卡控制器 | 2.1 |
| GPU_3D_Controller | PciDeviceType | GPU 3D控制器 | 2.1 |
| Moxa_Device | PciDeviceType | MOXA卡 | 2.1 |
| Generic | PciDeviceType | 一般设备 | 2.1 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | PciDeviceState | 启用 | 2.1 |
| Disabled | PciDeviceState | 停用 | 2.1 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Active | PciDeviceStatus | 就绪 | 2.1 |
| Attached | PciDeviceStatus | 已挂载 | 2.1 |
| System | PciDeviceStatus | 系统 | 2.1 |
#virtStatus
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| UNVIRTUALIZABLE | PciDeviceVirtStatus | 不可虚拟化 | 3.5.0 |
| SRIOV_VIRTUALIZABLE | PciDeviceVirtStatus | 支持SRIOV虚拟化 | 3.5.0 |
| VFIO_MDEV_VIRTUALIZABLE | PciDeviceVirtStatus | 支持VFIO_MDEV虚拟化 | 3.5.0 |
| SRIOV_VIRTUALIZED | PciDeviceVirtStatus | 已SRIOV虚拟化 | 3.5.0 |
| VFIO_MDEV_VIRTUALIZED | PciDeviceVirtStatus | 已VFIO_MDEV虚拟化 | 3.5.0 |
| SRIOV_VIRTUAL | PciDeviceVirtStatus | SRIOV虚拟设备 | 3.5.0 |
| UNKNOWN | PciDeviceVirtStatus | 未知 | 3.5.0 |
#chooser
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| None | PciDeviceChooser | 4.8.0 | |
| Device | PciDeviceChooser | 4.8.0 | |
| Spec | PciDeviceChooser | 4.8.0 |
#metaData
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| metaData | String | 2.1 | |
| metaDataEntries | List | 详情参考metaDataEntries | 2.1 |
#metaDataEntries
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| key | String | 键 | 2.1 |
| value | String | 值 | 2.1 |
| op | PciDeviceMetaDataOperator | 详情参考op | 2.1 |
#op
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Equal | PciDeviceMetaDataOperator | 相等 | 2.1 |
| Unequal | PciDeviceMetaDataOperator | 不等 | 2.1 |
#matchedPciDeviceOfferingRef
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| pciDeviceUuid | String | 2.1 | |
| pciDeviceOfferingUuid | String | 2.1 |
#mdevSpecRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| pciDeviceUuid | String | PCI设备UUID | 3.5.0 |
| mdevSpecUuid | String | MDEV设备规格UUID | 3.5.0 |
| effective | Boolean | 当前MDEV规格是否被用于切分该PCI设备 | 3.5.0 |
| createDate | Timestamp | 创建时间 | 3.5.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.5.0 |
SDK示例
Java
SDK
QueryEthernetVFAction action = new QueryEthernetVFAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEthernetVFAction.Result res = action.call();Python
SDK
QueryEthernetVFAction action = QueryEthernetVFAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryEthernetVFAction.Result res = action.call()修改虚拟机VF网卡高可用状态(ChangeVfNicHaState)
API请求
URLs
PUT zstack/v1/vm-instances/nics/{vfNicUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeVfNicHaState": {
"haState": "Enabled"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeVfNicHaState":{"haState":"Enabled"}}' \
http://localhost:8080/zstack/v1/vm-instances/nics/8536b111015d3fd289907c5f53c80153/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vfNicUuid | String | url | VF网卡UUID | 4.10.0 | |
| haState | String | body(包含在changeVfNicHaState结构中) |
高可用状态 |
|
4.10.0 |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"pciDeviceUuid": "4935759d5e543ff7bb9901262d67e805",
"haState": "Enabled",
"uuid": "5a39466d15e9303d8cd091be8f8b98a0",
"vmInstanceUuid": "0c9912e742793004bd585150a4e243d0",
"usedIpUuid": "6c1404d271ce3da4a5a845563b65ab55",
"l3NetworkUuid": "0d42b1c567da3721b04d1bc316b2e0cb",
"ip": "192.168.1.2",
"mac": "00:0c:29:bd:99:fc",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0,
"type": "VF",
"state": "enable"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| pciDeviceUuid | String | 网卡PCI地址 | 4.10.0 |
| haState | String | 高可用状态 | 4.10.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| vmInstanceUuid | String | 虚拟机UUID | 4.10.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.10.0 |
| ip | String | 4.10.0 | |
| mac | String | 4.10.0 | |
| hypervisorType | String | 4.10.0 | |
| netmask | String | 4.10.0 | |
| gateway | String | 4.10.0 | |
| metaData | String | 4.10.0 | |
| ipVersion | Integer | 4.10.0 | |
| driverType | String | 4.10.0 | |
| internalName | String | 4.10.0 | |
| deviceId | Integer | 4.10.0 | |
| type | String | 4.10.0 | |
| state | String | 4.10.0 | |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
| usedIps | List | 详情参考usedIps | 4.10.0 |
#usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| ipRangeUuid | String | IP段UUID | 4.10.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.10.0 |
| ipVersion | Integer | 4.10.0 | |
| ip | String | 4.10.0 | |
| netmask | String | 4.10.0 | |
| gateway | String | 4.10.0 | |
| usedFor | String | 4.10.0 | |
| ipInLong | long | 4.10.0 | |
| vmNicUuid | String | 虚拟机网卡UUID | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
#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 |
SDK示例
Java SDK
ChangeVfNicHaStateAction action = new ChangeVfNicHaStateAction();
action.vfNicUuid = "8536b111015d3fd289907c5f53c80153";
action.haState = "Enabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVfNicHaStateAction.Result res = action.call();Python SDK
action = ChangeVfNicHaStateAction()
action.vfNicUuid = "8536b111015d3fd289907c5f53c80153"
action.haState = "Enabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()