CreateVmInstanceFromVolume

API Request

URLs
POST zstack/v1/vm-instances/from/volume
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "vm1",
    "description": "this is a vm",
    "instanceOfferingUuid": "80c606e35bc038bbb102e31cae191ea2",
    "l3NetworkUuids": [
      "333817afcaf63f13a101f674761c8a77"
    ],
    "volumeUuid": "23984cd68b903fd4883aa962c70d83fc",
    "clusterUuid": "ada53eb6c42e34d3946ff1280718d9f2",
    "strategy": "InstantStart"
  },
  "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 POST -d '{"params":{"name":"vm1","description":"this is a vm","instanceOfferingUuid":"80c606e35bc038bbb102e31cae191ea2","l3NetworkUuids":["333817afcaf63f13a101f674761c8a77"],"volumeUuid":"23984cd68b903fd4883aa962c70d83fc","clusterUuid":"ada53eb6c42e34d3946ff1280718d9f2","strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/vm-instances/from/volume
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The resource name. 3.10.0
description String body (contained in the params structure) Optional. The detailed description of the resource. 3.10.0
instanceOfferingUuid String body (contained in the params structure) Optional. The instance offering UUID. Note: This parameter is optional if you choose the CPU number and memory size. 3.10.0
cpuNum Integer body (contained in the params structure) Optional. The CPU number or memory size. Note: This parameter is optional if you choose instanceOfferingUuid. 3.10.0
memorySize Long body (contained in the params structure) 3.10.0
l3NetworkUuids List body (contained in the params structure) The L3 network UUID.
  • Specifies one or more L3 networks. The VM instance will create one NIC on each L3 network.
3.10.0
type String body (contained in the params structure) Optional. The VM type.
  • The reserved field, which is no need to specify.
  • UserVm
  • ApplianceVm
3.10.0
volumeUuid String body (contained in the params structure) The volume UUID. 4.1.0
platform String body (contained in the params structure) Optional. The volume system platform.
  • Linux
  • Windows
  • Other
3.10.0
zoneUuid String body (contained in the params structure) Optional. The zone UUID.
  • If specified, the VM instance will will be created in the specified zone.
3.10.0
clusterUuid String body (contained in the params structure) Optional. The cluster UUID.
  • If specified, the VM instance will be created in the specified cluster. The resource priority of this parameter is higher than zoneUuid.
3.10.0
hostUuid String body (contained in the params structure) Optional. The host UUID.
  • If specified, the VM instance will be created in the specified host. The resource priority of this parameter is higher than zoneUuid and clusterUuid.
3.10.0
primaryStorageUuid String body (contained in the params structure) Optional. The primary storage UUID.
  • If specified, the root volume of the VM instance will be created in the specified primary storage.
3.10.0
defaultL3NetworkUuid String body (contained in the params structure) Optional. The default L3 network UUID.
  • When l3NetworkUuids specifies multiple L3 networks, this parameter specifies to provide the default L3 network.
  • If not specified, the first network of l3NetworkUuids will be selected as the default network.
3.10.0
strategy String body (contained in the params structure) Optional. The VM creation strategy.
  • After the VM instance is created, the VM instance is started immediately.
  • After the VM instance is created, the VM instance will not be started.
  • InstantStart
  • CreateStopped
3.10.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID.
  • If specified, the VM instance will use this field as UUID.
3.10.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 3.10.0
systemTags List body Optional. The system tags. 3.10.0
userTags List body Optional. The user tags. 3.10.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "33614668ae7d386c91d662928f60b23f",
    "name": "Test-VM",
    "description": "web server VM",
    "zoneUuid": "62f048b02e353ba4bdb9184ad7f54170",
    "clusterUuid": "ff753adc06c83d5ab2b0291f57b4745a",
    "imageUuid": "9291412f184f37a284b484b0788b24ca",
    "hostUuid": "0f9f5c6561d733d18a94577c4cd0976f",
    "lastHostUuid": "dc452dde2f7832b29bf91a0ddb6a004c",
    "instanceOfferingUuid": "b35adab33ba139b98ee20c1e2be702d3",
    "rootVolumeUuid": "f54fc6d488133688a6a7635f5c44a288",
    "platform": "Linux",
    "defaultL3NetworkUuid": "d82e3c622f933054a1939fb66e07681e",
    "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": "16198ebdef9c3f8084acd1a919eff4f2",
        "vmInstanceUuid": "33614668ae7d386c91d662928f60b23f",
        "usedIpUuid": "8eb3618f949a3e588acf9d8b0ee8293f",
        "l3NetworkUuid": "d82e3c622f933054a1939fb66e07681e",
        "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,
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "allVolumes": [
      {
        "uuid": "f54fc6d488133688a6a7635f5c44a288",
        "name": "Root-Volume-For-VM-33614668ae7d386c91d662928f60b23f",
        "primaryStorageUuid": "769061e63aec3278b1e6c3619d6da766",
        "vmInstanceUuid": "33614668ae7d386c91d662928f60b23f",
        "rootImageUuid": "9291412f184f37a284b484b0788b24ca",
        "installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-f54fc6d488133688a6a7635f5c44a288/f54fc6d488133688a6a7635f5c44a288.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. 3.10.0
inventory VmInstanceInventory See inventory. 3.10.0
#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. 3.10.0
description String The brief description of the error. 3.10.0
details String The details about the error. 3.10.0
elaboration String The reserved field. Default value: null. 3.10.0
opaque LinkedHashMap The reserved field. Default value: null. 3.10.0
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 3.10.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 3.10.0
name String The resource name. 3.10.0
description String The detailed description of the resource. 3.10.0
zoneUuid String The zone UUID. 3.10.0
clusterUuid String The cluster UUID. 3.10.0
imageUuid String The image UUID. 3.10.0
hostUuid String The host UUID. 3.10.0
lastHostUuid String 3.10.0
instanceOfferingUuid String The instance offering UUID. 3.10.0
rootVolumeUuid String The root volume UUID. 3.10.0
platform String 3.10.0
defaultL3NetworkUuid String 3.10.0
type String 3.10.0
hypervisorType String 3.10.0
memorySize Long 3.10.0
cpuNum Integer 3.10.0
cpuSpeed Long 3.10.0
allocatorStrategy String 3.10.0
createDate Timestamp The creation date. 3.10.0
lastOpDate Timestamp The last operation date. 3.10.0
state String 3.10.0
vmNics List See vmNics. 3.10.0
allVolumes List See allVolumes. 3.10.0
#vmNics
Name Type Description Starting Version
uuid String The resource UUID. 3.10.0
vmInstanceUuid String The VM instance UUID. 3.10.0
l3NetworkUuid String The L3 network UUID. 3.10.0
ip String The IP address. 3.10.0
mac String The MAC address. 3.10.0
hypervisorType String The hypervisor type. 3.10.0
netmask String The netmask. 3.10.0
gateway String The gateway. 3.10.0
metaData String The reserved field for internal use. 3.10.0
ipVersion Integer The IP version. 3.10.0
deviceId Integer The device ID. 3.10.0
createDate Timestamp The creation date. 3.10.0
lastOpDate Timestamp The last operation date. 3.10.0
usedIps List See usedIps . 3.10.0
#usedIps
Name Type Description Starting Version
uuid String The resource UUID. 3.10.0
ipRangeUuid String The IP range UUID. 3.10.0
l3NetworkUuid String The L3 network UUID. 3.10.0
ipVersion Integer The IP version. 3.10.0
ip String The IP address. 3.10.0
netmask String The netmask. 3.10.0
gateway String The gateway. 3.10.0
usedFor String 3.10.0
ipInLong long 3.10.0
vmNicUuid String The VM NIC UUID . 3.10.0
createDate Timestamp The creation date. 3.10.0
lastOpDate Timestamp The last operation date. 3.10.0
#allVolumes
Name Type Description Starting Version
uuid String The resource UUID. 3.10.0
name String The resource name. 3.10.0
description String The detailed description of the resource. 3.10.0
primaryStorageUuid String The primary storage UUID. 3.10.0
vmInstanceUuid String The VM instance UUID. 3.10.0
diskOfferingUuid String The disk offering UUID. 3.10.0
rootImageUuid String The root image UUID. 3.10.0
installPath String The installation path of volume in the primary storage. 3.10.0
type String The volume type, including data volume and root volume. 3.10.0
format String The volume format. 3.10.0
size Long The volume size. 3.10.0
actualSize Long The actual volume size. 3.10.0
deviceId Integer 3.10.0
state String Whether the volume is enabled. 3.10.0
status String The volume status. 3.10.0
createDate Timestamp The creation date. 3.10.0
lastOpDate Timestamp The last operation date. 3.10.0
isShareable Boolean Whether the volume is shared. 3.10.0
volumeQos String The volume QoS. Format: total=1048576. 3.10.0

SDK Sample

Java SDK
CreateVmInstanceFromVolumeAction action = new CreateVmInstanceFromVolumeAction();
action.name = "vm1";
action.description = "this is a vm";
action.instanceOfferingUuid = "80c606e35bc038bbb102e31cae191ea2";
action.l3NetworkUuids = asList("333817afcaf63f13a101f674761c8a77");
action.volumeUuid = "23984cd68b903fd4883aa962c70d83fc";
action.clusterUuid = "ada53eb6c42e34d3946ff1280718d9f2";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromVolumeAction.Result res = action.call();
Python SDK
CreateVmInstanceFromVolumeAction action = CreateVmInstanceFromVolumeAction()
action.name = "vm1"
action.description = "this is a vm"
action.instanceOfferingUuid = "80c606e35bc038bbb102e31cae191ea2"
action.l3NetworkUuids = [333817afcaf63f13a101f674761c8a77]
action.volumeUuid = "23984cd68b903fd4883aa962c70d83fc"
action.clusterUuid = "ada53eb6c42e34d3946ff1280718d9f2"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmInstanceFromVolumeAction.Result res = action.call()