ChangeVmImage
API Request
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeVmImage": {
"imageUuid": "dbfd52c2f87c39cda8c8945fca8d6a5a"
},
"systemTags": [],
"userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeVmImage":{"imageUuid":"dbfd52c2f87c39cda8c8945fca8d6a5a"}}' \
http://localhost:8080/zstack/v1/vm-instances/af9e42b52dc836dfac3ee89b08c47488/actionsRequest Parameters
Note:
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 2.2 | |
| imageUuid | String | body (contained in the changeVmImage structure) | The image UUID. | 2.2 | |
| resourceUuid | String | body (contained in the changeVmImage structure) | Optional. The resource UUID. | 2.2 | |
| systemTags | List | body | Optional. The system tags. | 2.2 | |
| userTags | List | body | Optional. The user tags. | 2.2 |
Note:
- When you change the root volume of a VM instance in ZStack Cloud, you can specify the Ceph pool where the
root volume is located by adding the rootPoolName option to
SystemTags. The SystemTag is passed by using the
rootPoolName parameter.
- Format of the rootPoolName option:
ceph::rootPoolName::xxx. Here, xxx is the name of the Ceph pool. - Example:
ceph::rootPoolName::pri-v-r-26e11ca6814d4e1ba504d845f7848db3
- Format of the rootPoolName option:
API Response
Sample
Response
{
"inventory": {
"uuid": "8753ddd9d41d3e1c81bca779096325e6",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "8f13ce3cefcc3b4f905140613c0790e9",
"clusterUuid": "48574e91679f376f9443d75bd3deabd3",
"imageUuid": "d20e62e8cab133498f1456c14e210644",
"hostUuid": "1f74c3ba1d8a38afbc2c00b024b9df6f",
"lastHostUuid": "9220f51b605a308ab2d540541261d452",
"instanceOfferingUuid": "d1fe019ddd65376491f5b992dbe52f9d",
"rootVolumeUuid": "d4131773654237c997b00fad3102d30d",
"platform": "Linux",
"defaultL3NetworkUuid": "f12a1735a9f33a86a16d9487351832ac",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8.589934592E9,
"cpuNum": 1.0,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "6364c6ddbac03148b680f477761fd87a",
"vmInstanceUuid": "8753ddd9d41d3e1c81bca779096325e6",
"usedIpUuid": "996010937c043cee98258e261191d3e4",
"l3NetworkUuid": "f12a1735a9f33a86a16d9487351832ac",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "d4131773654237c997b00fad3102d30d",
"name": "Root-Volume-For-VM-8753ddd9d41d3e1c81bca779096325e6",
"primaryStorageUuid": "080271df17b53de2857ab4728bafb21d",
"vmInstanceUuid": "8753ddd9d41d3e1c81bca779096325e6",
"diskOfferingUuid": "0fa1ba3b260633ecaa74111268b22d11",
"rootImageUuid": "d20e62e8cab133498f1456c14e210644",
"installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-d4131773654237c997b00fad3102d30d/d4131773654237c997b00fad3102d30d.qcow2",
"type": "Root",
"format": "qcow2",
"size": 1.073741824E11,
"actualSize": 2.147483648E10,
"deviceId": 0.0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.2 |
| inventory | VmInstanceInventory | See inventory. | 2.2 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.2 |
| description | String | The brief description of the error. | 2.2 |
| details | String | The details about the error. | 2.2 |
| elaboration | String | The reserved field. Default value: null. | 2.2 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.2 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.2 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.2 |
| name | String | The resource name. | 2.2 |
| description | String | The detailed description of the resource. | 2.2 |
| zoneUuid | String | The zone UUID. | 2.2 |
| clusterUuid | String | The cluster UUID. | 2.2 |
| imageUuid | String | The image UUID. | 2.2 |
| hostUuid | String | The host UUID. | 2.2 |
| lastHostUuid | String | 2.2 | |
| instanceOfferingUuid | String | The instance offering UUID. | 2.2 |
| rootVolumeUuid | String | The root volume UUID. | 2.2 |
| platform | String | 2.2 | |
| defaultL3NetworkUuid | String | 2.2 | |
| type | String | 2.2 | |
| hypervisorType | String | 2.2 | |
| memorySize | Long | 2.2 | |
| cpuNum | Integer | 2.2 | |
| cpuSpeed | Long | 2.2 | |
| allocatorStrategy | String | 2.2 | |
| createDate | Timestamp | The creation date. | 2.2 |
| lastOpDate | Timestamp | The last operation date. | 2.2 |
| state | String | 2.2 | |
| vmNics | List | See vmNics. | 2.2 |
| allVolumes | List | See allVolumes. | 2.2 |
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.2 |
| vmInstanceUuid | String | The VM instance UUID. | 2.2 |
| l3NetworkUuid | String | The L3 network UUID. | 2.2 |
| ip | String | 2.2 | |
| mac | String | 2.2 | |
| netmask | String | 2.2 | |
| gateway | String | 2.2 | |
| metaData | String | 2.2 | |
| deviceId | Integer | 2.2 | |
| createDate | Timestamp | The creation date. | 2.2 |
| lastOpDate | Timestamp | The last operation date. | 2.2 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.2 |
| name | String | The resource name. | 2.2 |
| description | String | The detailed description of the resource. | 2.2 |
| primaryStorageUuid | String | The primary storage UUID. | 2.2 |
| vmInstanceUuid | String | The VM instance UUID. | 2.2 |
| diskOfferingUuid | String | The disk offering UUID. | 2.2 |
| rootImageUuid | String | 2.2 | |
| installPath | String | 2.2 | |
| type | String | 2.2 | |
| format | String | 2.2 | |
| size | Long | 2.2 | |
| actualSize | Long | 2.2 | |
| deviceId | Integer | 2.2 | |
| state | String | 2.2 | |
| status | String | 2.2 | |
| createDate | Timestamp | The creation date. | 2.2 |
| lastOpDate | Timestamp | The last operation date. | 2.2 |
| isShareable | Boolean | 2.2 |
SDK Sample
Java
SDK
ChangeVmImageAction action = new ChangeVmImageAction();
action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488";
action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmImageAction.Result res = action.call();Python
SDK
ChangeVmImageAction action = ChangeVmImageAction()
action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488"
action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeVmImageAction.Result res = action.call()