虚拟机相关接口
加载网卡到虚拟机
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' \
http://localhost:8080/zstack/v1/vm-instances/4fea63520ff63f5f9856acd619add4f5/nices/8b22e01e4bf43b1dab1530d2b362bbc5参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmNicUuid | String | url | 虚拟机网卡UUID | 4.0.0 | |
| vmInstanceUuid | List | url | 虚拟机UUID | 4.0.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.0.0 | |
| userTags (可选) | List | body | 用户标签 | 4.0.0 |
API返回
返回示例
{
"inventory": {
"uuid": "afbd67886d773a45af9a20071bcb09bb",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "4b9ddab3f5f738f1a0161f5cf5f33f5c",
"clusterUuid": "d7061d85666a380cb3dda4cc7f9f16ee",
"imageUuid": "179a3412da4a32faa927eae552348907",
"hostUuid": "6ee062370eee3df58623fa99be0b2ce0",
"lastHostUuid": "09fdbebbaea73df79b744ad0d4bd7088",
"instanceOfferingUuid": "6dc0db981e68348e89ac79ed18fa4b24",
"rootVolumeUuid": "a876397202ac3d1daf9f4ea67e75e13d",
"platform": "Linux",
"defaultL3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8589934592,
"cpuNum": 1,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "b9415d324b50301e923a990bf65352d0",
"vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
"usedIpUuid": "76a49549cb183d35865276187afb482b",
"l3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
"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,
"state": "enable",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "a876397202ac3d1daf9f4ea67e75e13d",
"name": "Root-Volume-For-VM-afbd67886d773a45af9a20071bcb09bb",
"primaryStorageUuid": "336625bac9e0326b9a9abc7801ef2c86",
"vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
"diskOfferingUuid": "475f8e09aae2389ea6945b46601aa683",
"rootImageUuid": "179a3412da4a32faa927eae552348907",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-a876397202ac3d1daf9f4ea67e75e13d/a876397202ac3d1daf9f4ea67e75e13d.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.0.0 |
| inventory | VmInstanceInventory | 详情参考inventory | 4.0.0 |
error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.0.0 |
| description | String | 错误的概要描述 | 4.0.0 |
| details | String | 错误的详细信息 | 4.0.0 |
| elaboration | String | 保留字段,默认为null | 4.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.0.0 |
inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 资源名称 | 4.0.0 |
| description | String | 资源的详细描述 | 4.0.0 |
| zoneUuid | String | 数据中心UUID | 4.0.0 |
| clusterUuid | String | 集群UUID | 4.0.0 |
| imageUuid | String | 镜像UUID | 4.0.0 |
| hostUuid | String | 主机UUID | 4.0.0 |
| lastHostUuid | String | 4.0.0 | |
| instanceOfferingUuid | String | 4.0.0 | |
| rootVolumeUuid | String | 根硬盘UUID | 4.0.0 |
| platform | String | 4.0.0 | |
| architecture | String | 0.6 | |
| defaultL3NetworkUuid | String | 4.0.0 | |
| type | String | 4.0.0 | |
| hypervisorType | String | 4.0.0 | |
| memorySize | Long | 4.0.0 | |
| cpuNum | Integer | 4.0.0 | |
| cpuSpeed | Long | 4.0.0 | |
| allocatorStrategy | String | 4.0.0 | |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
| state | String | 4.0.0 | |
| guestOsType | String | 4.1.2 | |
| vmNics | List | 详情参考vmNics | 4.0.0 |
| allVolumes | List | 详情参考allVolumes | 4.0.0 |
| vmCdRoms | List | 详情参考vmCdRoms | 0.6 |
vmNics
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| vmInstanceUuid | String | 虚拟机UUID | 4.0.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.0.0 |
| ip | String | IP地址 | 4.0.0 |
| mac | String | MAC地址 | 4.0.0 |
| hypervisorType | String | 虚拟化类型 | 4.0.0 |
| netmask | String | 子网掩码 | 4.0.0 |
| gateway | String | 网关 | 4.0.0 |
| metaData | String | 4.0.0 | |
| ipVersion | Integer | IP地址版本 | 4.0.0 |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | 设备ID | 4.0.0 |
| type | String | 网卡类型 | 4.0.0 |
| state | String | 网卡状态 | 4.7.13 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
| usedIps | List | 详情参考usedIps | 4.0.0 |
usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| ipRangeUuid | String | IP段UUID | 4.0.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.0.0 |
| ipVersion | Integer | IP协议号 | 4.0.0 |
| ip | String | IP地址 | 4.0.0 |
| netmask | String | 网络掩码 | 4.0.0 |
| gateway | String | 网关地址 | 4.0.0 |
| usedFor | String | 4.0.0 | |
| ipInLong | long | 4.0.0 | |
| vmNicUuid | String | 虚拟机网卡UUID | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
allVolumes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 资源名称 | 4.0.0 |
| description | String | 资源的详细描述 | 4.0.0 |
| primaryStorageUuid | String | 数据存储UUID | 4.0.0 |
| vmInstanceUuid | String | 虚拟机UUID | 4.0.0 |
| diskOfferingUuid | String | 硬盘规格UUID | 4.0.0 |
| rootImageUuid | String | 硬盘根镜像UUID | 4.0.0 |
| installPath | String | 硬盘在数据存储上的路径 | 4.0.0 |
| type | String | 硬盘类型,数据硬盘/根硬盘 | 4.0.0 |
| format | String | 硬盘格式 | 4.0.0 |
| size | Long | 硬盘大小 | 4.0.0 |
| actualSize | Long | 硬盘真实大小 | 4.0.0 |
| deviceId | Integer | 4.0.0 | |
| state | String | 硬盘是否开启 | 4.0.0 |
| status | String | 硬盘状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
| isShareable | Boolean | 是否共享硬盘 | 4.0.0 |
| volumeQos | String | 硬盘Qos,格式如total=1048576 | 4.0.0 |
| lastDetachDate | Timestamp | 4.7.13 | |
| lastVmInstanceUuid | String | 4.7.13 |
vmCdRoms
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.7.13 |
| vmInstanceUuid | String | 虚拟机UUID | 4.7.13 |
| deviceId | Integer | 4.7.13 | |
| isoUuid | String | 4.7.13 | |
| isoInstallPath | String | 4.7.13 | |
| name | String | 资源名称 | 4.7.13 |
| description | String | 资源的详细描述 | 4.7.13 |
| createDate | Timestamp | 创建时间 | 4.7.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.7.13 |
SDK示例
Java SDK
AttachVmNicToVmAction action = new AttachVmNicToVmAction();
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5";
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachVmNicToVmAction.Result res = action.call();Python SDK
action = AttachVmNicToVmAction()
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5"
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()