虚拟机相关接口
设置虚拟机时钟同步
Headers
Authorization: OAuth the-session-uuidBody
{
"setVmClockTrack": {
"track": "guest",
"syncAfterVMResume": true,
"intervalInSeconds": 60
},
"systemTags": [],
"userTags": []
}上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT '{"setVmClockTrack":{"track":"guest","syncAfterVMResume":true,"intervalInSeconds":60.0}}' http://localhost:8080/zstack/v1/vm-instances/cc0a313462243900b6c843ff427b7f0e/actions参数列表
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
uuid | String | url | 资源的UUID,唯一标示该资源 |
| 4.1.0 |
track | String | body(包含在setVmClockTrack结构中) |
|
| 4.1.0 |
syncAfterVMResume (可选) | Boolean | body(包含在setVmClockTrack结构中) | 暂停到恢复是否同步 |
| 4.4.24 |
intervalInSeconds (可选) | Integer | body(包含在setVmClockTrack结构中) | 定期同步时间间隔 |
| 4.4.24 |
systemTags (可选) | List | body | 系统标签 |
| 4.1.0 |
userTags (可选) | List | body | 用户标签 |
| 4.1.0 |
API返回
返回示例
{
"inventory": {
"uuid": "19d64f55a9723e59849c0f9357a0dded",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "553326a3b554380ca4e4b2976efa4df5",
"clusterUuid": "c9a8ba243c5a3d59b144e4e1ace143a2",
"imageUuid": "e4297acdd9b43e3f9b7a8ec74211a3f2",
"hostUuid": "f841ef12962037369ea4d8f3ba4c9c28",
"lastHostUuid": "3b6273ea6b1a384584178e11f05bf1f0",
"instanceOfferingUuid": "9ce1349c65ff3c80a423267837f5f34e",
"rootVolumeUuid": "5319e0ae2b483949bf25b059a674dbc8",
"platform": "Linux",
"defaultL3NetworkUuid": "c715b758cd843ac997ccdfbbcc9097cc",
"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": "Stopped",
"vmNics": [
{
"uuid": "8585080b6b5236a5875e8162c062e551",
"vmInstanceUuid": "19d64f55a9723e59849c0f9357a0dded",
"usedIpUuid": "c0bbe89468fa3b2aa6dc4e8aaa6df3f7",
"l3NetworkUuid": "c715b758cd843ac997ccdfbbcc9097cc",
"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": "5319e0ae2b483949bf25b059a674dbc8",
"name": "Root-Volume-For-VM-19d64f55a9723e59849c0f9357a0dded",
"primaryStorageUuid": "0e4e3cf961873074b8b3eca3bc693ece",
"vmInstanceUuid": "19d64f55a9723e59849c0f9357a0dded",
"diskOfferingUuid": "f1b95ad6d26e336e8809764ec2936fd2",
"rootImageUuid": "e4297acdd9b43e3f9b7a8ec74211a3f2",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-5319e0ae2b483949bf25b059a674dbc8/5319e0ae2b483949bf25b059a674dbc8.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 | 4.1.0 | |
| inventory | VmInstanceInventory | 详情参考inventory | 4.1.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.1.0 |
error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.1.0 |
| description | String | 错误的概要描述 | 4.1.0 |
| details | String | 错误的详细信息 | 4.1.0 |
| elaboration | String | 保留字段,默认为null | 4.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.1.0 |
inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| name | String | 资源名称 | 4.1.0 |
| description | String | 资源的详细描述 | 4.1.0 |
| zoneUuid | String | 数据中心UUID | 4.1.0 |
| clusterUuid | String | 集群UUID | 4.1.0 |
| imageUuid | String | 镜像UUID | 4.1.0 |
| hostUuid | String | 主机UUID | 4.1.0 |
| lastHostUuid | String | 4.1.0 | |
| instanceOfferingUuid | String | 计算规格UUID | 4.1.0 |
| rootVolumeUuid | String | 根硬盘UUID | 4.1.0 |
| platform | String | 4.1.0 | |
| architecture | String | 0.6 | |
| defaultL3NetworkUuid | String | 4.1.0 | |
| type | String | 4.1.0 | |
| hypervisorType | String | 4.1.0 | |
| memorySize | Long | 4.1.0 | |
| cpuNum | Integer | 4.1.0 | |
| cpuSpeed | Long | 4.1.0 | |
| allocatorStrategy | String | 4.1.0 | |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
| state | String | 4.1.0 | |
| guestOsType | String | 4.1.2 | |
| vmNics | List | 详情参考vmNics | 4.1.0 |
| allVolumes | List | 详情参考allVolumes | 4.1.0 |
| vmCdRoms | List | 详情参考vmCdRoms | 0.6 |
vmNics
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| vmInstanceUuid | String | 虚拟机UUID | 4.1.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.1.0 |
| ip | String | IP地址 | 4.1.0 |
| mac | String | MAC地址 | 4.1.0 |
| hypervisorType | String | 虚拟化类型 | 4.1.0 |
| netmask | String | 子网掩码 | 4.1.0 |
| gateway | String | 网关 | 4.1.0 |
| metaData | String | 4.1.0 | |
| ipVersion | Integer | IP地址版本 | 4.1.0 |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | 设备ID | 4.1.0 |
| type | String | 网卡类型 | 4.1.0 |
| state | String | 网卡状态 | 4.7.13 |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
| usedIps | List | 详情参考usedIps | 4.1.0 |
usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| ipRangeUuid | String | IP段UUID | 4.1.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.1.0 |
| ipVersion | Integer | IP协议号 | 4.1.0 |
| ip | String | IP地址 | 4.1.0 |
| netmask | String | 网络掩码 | 4.1.0 |
| gateway | String | 网关地址 | 4.1.0 |
| usedFor | String | 4.1.0 | |
| ipInLong | long | 4.1.0 | |
| vmNicUuid | String | 虚拟机网卡UUID | 4.1.0 |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
allVolumes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| name | String | 资源名称 | 4.1.0 |
| description | String | 资源的详细描述 | 4.1.0 |
| primaryStorageUuid | String | 数据存储UUID | 4.1.0 |
| vmInstanceUuid | String | 虚拟机UUID | 4.1.0 |
| diskOfferingUuid | String | 硬盘规格UUID | 4.1.0 |
| rootImageUuid | String | 硬盘根镜像UUID | 4.1.0 |
| installPath | String | 硬盘在数据存储上的路径 | 4.1.0 |
| type | String | 硬盘类型,数据硬盘/根硬盘 | 4.1.0 |
| format | String | 硬盘格式 | 4.1.0 |
| size | Long | 硬盘大小 | 4.1.0 |
| actualSize | Long | 硬盘真实大小 | 4.1.0 |
| deviceId | Integer | 4.1.0 | |
| state | String | 硬盘是否开启 | 4.1.0 |
| status | String | 硬盘状态 | 4.1.0 |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
| isShareable | Boolean | 是否共享硬盘 | 4.1.0 |
| volumeQos | String | 硬盘Qos,格式如total=1048576 | 4.1.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
SetVmClockTrackAction action = new SetVmClockTrackAction();
action.uuid = "cc0a313462243900b6c843ff427b7f0e";
action.track = "guest";
action.syncAfterVMResume = true;
action.intervalInSeconds = 60;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVmClockTrackAction.Result res = action.call();Python SDK
action = SetVmClockTrackAction()
action.uuid = "cc0a313462243900b6c843ff427b7f0e"
action.track = "guest"
action.syncAfterVMResume = true
action.intervalInSeconds = 60
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()