Create VM Instance from Volume Snapshot
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "vm1",
"description": "this is a vm",
"instanceOfferingUuid": "6900e329296732aca0e3658bcdcdd3ce",
"l3NetworkUuids": [
"990ffab4793036d29fc92142889f9ef2"
],
"clusterUuid": "cd44bab6f1d43e59bbc885f869e89388",
"strategy": "InstantStart"
},
"systemTags": [],
"userTags": []
}In the above example, systemTags and userTags fields can be omitted. They are listed to indicate that the body can contain these two fields.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"vm1","description":"this is a vm","instanceOfferingUuid":"6900e329296732aca0e3658bcdcdd3ce","l3NetworkUuids":["990ffab4793036d29fc92142889f9ef2"],"clusterUuid":"cd44bab6f1d43e59bbc885f869e89388","strategy":"InstantStart"}}' \
http://localhost:8080/zstack/v1/vm-instances/from/volume-snapshots/f81c959344783f19ae4fc76f1e770201Parameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
name | String | body (contained in params structure) | Resource name |
| 4.1.0 |
description (Optional) | String | body (contained in params structure) | Detailed description of the resource |
| 4.1.0 |
instanceOfferingUuid (Optional) | String | body (contained in params structure) | Instance offering UUID |
| 4.1.0 |
cpuNum (Optional) | Integer | body (contained in params structure) | CPU number |
| 4.1.0 |
memorySize (Optional) | Long | body (contained in params structure) | Memory size |
| 4.1.0 |
l3NetworkUuids | List | body (contained in params structure) | L3 network UUID list |
| 4.1.0 |
type (Optional) | String | body (contained in params structure) | VM type |
| 4.1.0 |
vmNicParams (Optional) | String | body (contained in params structure) | NIC information |
| 4.0.0 |
volumeSnapshotUuid | String | url | Volume snapshot group UUID |
| 4.1.0 |
platform (Optional) | String | body (contained in params structure) | VM platform |
| 4.1.0 |
zoneUuid (Optional) | String | body (contained in params structure) | Data Center UUID |
| 4.1.0 |
clusterUuid (Optional) | String | body (contained in params structure) | Cluster UUID |
| 4.1.0 |
hostUuid (Optional) | String | body (contained in params structure) | Host UUID |
| 4.1.0 |
primaryStorageUuid (Optional) | String | body (contained in params structure) | Primary Storage UUID |
| 4.1.0 |
defaultL3NetworkUuid (Optional) | String | body (contained in params structure) | Default L3 network UUID |
| 4.1.0 |
strategy (Optional) | String | body (contained in params structure) | Creation strategy |
| 4.1.0 |
resourceUuid (Optional) | String | body (contained in params structure) | Resource UUID |
| 4.1.0 |
tagUuids (Optional) | List | body (contained in params structure) | Tag UUID list |
| 4.1.0 |
systemTags (Optional) | List | body | System Tags |
| 4.1.0 |
userTags (Optional) | List | body | User Tags |
| 4.1.0 |
rootVolumeSystemTags (Optional) | List | body (contained in | Root volume system tags |
| 4.1.0 |
reservedMemorySize (Optional) | Long | body (contained in |
|
| 4.7.21 |
API Response
Response Example
{
"inventory": {
"uuid": "56331ef0c0713bc09dc2dc160fd4d48a",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "49783ceb7da734aab1ea137f2b7b82ac",
"clusterUuid": "ebfbd2a6e08a3b78b70c9b6093f40d37",
"imageUuid": "9a4914937dcd3149810793f8b040e8ad",
"hostUuid": "2665407c38f932c08f3fb33bb6c8f3f4",
"lastHostUuid": "2a847b5699b535d7a78b57cd411ffeac",
"instanceOfferingUuid": "041ff292e60f31079dd8e6e3c9c26c72",
"rootVolumeUuid": "98648a22b2c639ee88571bf1c429caba",
"platform": "Linux",
"defaultL3NetworkUuid": "4f80edbb396b346c9af4dcce48f94fb5",
"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": "1e1b705f391c3f40a2b6ae447d0e12ca",
"vmInstanceUuid": "56331ef0c0713bc09dc2dc160fd4d48a",
"usedIpUuid": "bf85263c007d3959a166599181daa4b7",
"l3NetworkUuid": "4f80edbb396b346c9af4dcce48f94fb5",
"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": "98648a22b2c639ee88571bf1c429caba",
"name": "Root-Volume-For-VM-56331ef0c0713bc09dc2dc160fd4d48a",
"primaryStorageUuid": "406362409f493e14952262df535e9cf8",
"vmInstanceUuid": "56331ef0c0713bc09dc2dc160fd4d48a",
"rootImageUuid": "9a4914937dcd3149810793f8b040e8ad",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-98648a22b2c639ee88571bf1c429caba/98648a22b2c639ee88571bf1c429caba.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"
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. See error | 4.1.0 |
| inventory | VmInstanceInventory | See inventory | 4.1.0 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 4.1.0 |
| description | String | Brief description of the error | 4.1.0 |
| details | String | Detailed error information | 4.1.0 |
| elaboration | String | Reserved field, defaults to null | 4.1.0 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 4.1.0 |
| cause | ErrorCode | Root cause. The source error that triggered the current error. This field is null if there is no original error | 4.1.0 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.1.0 |
| name | String | Resource name | 4.1.0 |
| description | String | Detailed description of the resource | 4.1.0 |
| zoneUuid | String | Data Center UUID | 4.1.0 |
| clusterUuid | String | Cluster UUID | 4.1.0 |
| imageUuid | String | Image UUID | 4.1.0 |
| hostUuid | String | Host UUID | 4.1.0 |
| lastHostUuid | String | 4.1.0 | |
| instanceOfferingUuid | String | Instance offering UUID | 4.1.0 |
| rootVolumeUuid | String | Root volume UUID | 4.1.0 |
| platform | String | 4.1.0 | |
| 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 | Creation time | 4.1.0 |
| lastOpDate | Timestamp | Last modification time | 4.1.0 |
| state | String | 4.1.0 | |
| guestOsType | String | 4.1.2 | |
| vmNics | List | See vmNics | 4.1.0 |
| allVolumes | List | See allVolumes | 4.1.0 |
| vmCdRoms | List | See vmCdRoms | 0.6 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.1.0 |
| vmInstanceUuid | String | VM UUID | 4.1.0 |
| l3NetworkUuid | String | L3 network UUID | 4.1.0 |
| ip | String | IP address | 4.1.0 |
| mac | String | MAC address | 4.1.0 |
| hypervisorType | String | Hypervisor type | 4.1.0 |
| netmask | String | Netmask | 4.1.0 |
| gateway | String | Gateway | 4.1.0 |
| metaData | String | 4.1.0 | |
| ipVersion | Integer | IP version | 4.1.0 |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | Device ID | 4.1.0 |
| type | String | NIC type | 4.1.0 |
| state | String | NIC state | 4.7.13 |
| createDate | Timestamp | Creation time | 4.1.0 |
| lastOpDate | Timestamp | Last modification time | 4.1.0 |
| usedIps | List | See usedIps | 4.1.0 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.1.0 |
| ipRangeUuid | String | IP range UUID | 4.1.0 |
| l3NetworkUuid | String | L3 network UUID | 4.1.0 |
| ipVersion | Integer | IP protocol number | 4.1.0 |
| ip | String | IP address | 4.1.0 |
| netmask | String | Network mask | 4.1.0 |
| gateway | String | Gateway address | 4.1.0 |
| usedFor | String | 4.1.0 | |
| ipInLong | long | 4.1.0 | |
| vmNicUuid | String | VM NIC UUID | 4.1.0 |
| createDate | Timestamp | Creation time | 4.1.0 |
| lastOpDate | Timestamp | Last modification time | 4.1.0 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.1.0 |
| name | String | Resource name | 4.1.0 |
| description | String | Detailed description of the resource | 4.1.0 |
| primaryStorageUuid | String | Primary Storage UUID | 4.1.0 |
| vmInstanceUuid | String | VM UUID | 4.1.0 |
| diskOfferingUuid | String | Disk offering UUID | 4.1.0 |
| rootImageUuid | String | Root image UUID | 4.1.0 |
| installPath | String | Volume install path on the primary storage | 4.1.0 |
| type | String | Volume type, data volume/root volume | 4.1.0 |
| format | String | Volume format | 4.1.0 |
| size | Long | Volume size | 4.1.0 |
| actualSize | Long | Actual volume size | 4.1.0 |
| deviceId | Integer | 4.1.0 | |
| state | String | Volume state | 4.1.0 |
| status | String | Volume status | 4.1.0 |
| createDate | Timestamp | Creation time | 4.1.0 |
| lastOpDate | Timestamp | Last modification time | 4.1.0 |
| isShareable | Boolean | Whether it is a shared volume | 4.1.0 |
| volumeQos | String | 4.1.0 | |
| lastDetachDate | Timestamp | 4.7.13 | |
| lastVmInstanceUuid | String | 4.7.13 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.7.13 |
| vmInstanceUuid | String | VM UUID | 4.7.13 |
| deviceId | Integer | 4.7.13 | |
| isoUuid | String | 4.7.13 | |
| isoInstallPath | String | 4.7.13 | |
| name | String | Resource name | 4.7.13 |
| description | String | Detailed description of the resource | 4.7.13 |
| createDate | Timestamp | Creation time | 4.7.13 |
| lastOpDate | Timestamp | Last modification time | 4.7.13 |
SDK Examples
Java SDK
CreateVmInstanceFromVolumeSnapshotAction action = new CreateVmInstanceFromVolumeSnapshotAction();
action.name = "vm1";
action.description = "this is a vm";
action.instanceOfferingUuid = "6900e329296732aca0e3658bcdcdd3ce";
action.l3NetworkUuids = asList("990ffab4793036d29fc92142889f9ef2");
action.volumeSnapshotUuid = "f81c959344783f19ae4fc76f1e770201";
action.clusterUuid = "cd44bab6f1d43e59bbc885f869e89388";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromVolumeSnapshotAction.Result res = action.call();Python SDK
action = CreateVmInstanceFromVolumeSnapshotAction()
action.name = "vm1"
action.description = "this is a vm"
action.instanceOfferingUuid = "6900e329296732aca0e3658bcdcdd3ce"
action.l3NetworkUuids = [990ffab4793036d29fc92142889f9ef2]
action.volumeSnapshotUuid = "f81c959344783f19ae4fc76f1e770201"
action.clusterUuid = "cd44bab6f1d43e59bbc885f869e89388"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()