VM Related Interfaces

Change VM Image

PUT/zstack/v1/vm-instances/{vmInstanceUuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "changeVmImage": {
    "imageUuid": "dbfd52c2f87c39cda8c8945fca8d6a5a"
  },
  "systemTags": [],
  "userTags": []
}

In the example above, 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 PUT -d '{"changeVmImage":{"imageUuid":"dbfd52c2f87c39cda8c8945fca8d6a5a"}}' \
http://localhost:8080/zstack/v1/vm-instances/af9e42b52dc836dfac3ee89b08c47488/actions

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmInstanceUuidStringurlVirtual Machine UUID 2.2
imageUuidStringbody (contained in changeVmImage structure)Image UUID 2.2
systemTags (Optional)ListbodySystem Tags 2.2
userTags (Optional)ListbodyUser Tags 2.2
resourceUuid (Optional)Stringbody (contained in changeVmImage structure)  0.6
tagUuids (Optional)Listbody (contained in changeVmImage structure)Tag UUID list 0.6
  • ZSvirt supports specifying the distributed storage pool where the root disk is located when changing the VM root disk. SystemTags adds rootPoolName option, using rootPoolName parameter to pass the SystemTag.
  • Option format: ceph::rootPoolName::xxx, where xxx represents the pool name
  • For example: ceph::rootPoolName::pri-v-r-26e11ca6814d4e1ba504d845f7848db3

API Response

Response Example

{
  "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": 8589934592,
    "cpuNum": 1,
    "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2: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",
        "hypervisorType": "KVM",
        "netmask": "255.255.255.0",
        "gateway": "192.168.1.1",
        "deviceId": 0,
        "createDate": "Nov 14, 2017 2:20:57 PM",
        "lastOpDate": "Nov 14, 2017 2:20:57 PM"
      }
    ],
    "allVolumes": [
      {
        "uuid": "d4131773654237c997b00fad3102d30d",
        "name": "Root-Volume-For-VM-8753ddd9d41d3e1c81bca779096325e6",
        "primaryStorageUuid": "080271df17b53de2857ab4728bafb21d",
        "vmInstanceUuid": "8753ddd9d41d3e1c81bca779096325e6",
        "diskOfferingUuid": "0fa1ba3b260633ecaa74111268b22d11",
        "rootImageUuid": "d20e62e8cab133498f1456c14e210644",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-d4131773654237c997b00fad3102d30d/d4131773654237c997b00fad3102d30d.qcow2",
        "type": "Root",
        "format": "qcow2",
        "size": 107374182400,
        "actualSize": 21474836480,
        "deviceId": 0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 2:20:57 PM",
        "lastOpDate": "Nov 14, 2017 2:20:57 PM"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed. When the operation succeeds, this field is null. For details, see error2.2
inventoryVmInstanceInventoryFor details, see inventory2.2

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier of the error, for example SYS.1000, HOST.10012.2
descriptionStringBrief description of the error2.2
detailsStringDetailed error information2.2
elaborationStringReserved field, defaults to null2.2
opaqueLinkedHashMapReserved field, defaults to null2.2
causeErrorCodeRoot cause. The error that triggered the current error. If there is no original error, this field is null2.2

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource2.2
nameStringResource name2.2
descriptionStringResource description2.2
zoneUuidStringData Center UUID2.2
clusterUuidStringCluster UUID2.2
imageUuidStringImage UUID2.2
hostUuidStringHost UUID2.2
lastHostUuidStringLast Host UUID2.2
instanceOfferingUuidStringCompute Offering UUID2.2
rootVolumeUuidStringRoot Disk UUID2.2
platformStringVirtual Machine platform, whether Windows / Linux or others2.2
architectureStringVirtual Machine architecture, whether x86_64 / aarch64 or others2.2
defaultL3NetworkUuidStringDefault Distributed Port Group UUID2.2
typeStringVirtual Machine type, whether for user use or for platform special purposes2.2
hypervisorTypeStringVirtual Machine hypervisor type, generally KVM2.2
memorySizeLongMemory size2.2
cpuNumIntegerCPU count2.2
cpuSpeedLongCPU speed2.2
allocatorStrategyStringVirtual Machine allocation strategy2.2
createDateTimestampCreation time2.2
lastOpDateTimestampLast modification time2.2
stateStringWhether the Virtual Machine is enabled2.2
guestOsTypeStringVirtual Machine host operating system type2.2
vmNicsListFor details, see vmNics2.2
allVolumesListFor details, see allVolumes2.2
vmCdRomsListFor details, see vmCdRoms2.2

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource2.2
vmInstanceUuidStringVirtual Machine UUID2.2
l3NetworkUuidStringDistributed Port Group UUID2.2
ipString 2.2
macString 2.2
hypervisorTypeString 2.2
netmaskString 2.2
gatewayString 2.2
metaDataString 2.2
ipVersionInteger 2.2
driverTypeString 2.2
internalNameString 2.2
deviceIdInteger 2.2
typeString 2.2
stateStringNIC status2.2
createDateTimestampCreation time2.2
lastOpDateTimestampLast modification time2.2
usedIpsListFor details, see usedIps2.2

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.10.0
ipRangeUuidStringIP Range UUID4.10.0
l3NetworkUuidStringDistributed Port Group UUID4.10.0
ipVersionIntegerIP protocol number4.10.0
ipStringIP address4.10.0
netmaskStringSubnet mask4.10.0
gatewayStringGateway address4.10.0
usedForStringAllocation reason4.10.0
ipInLonglongIP address stored in Long format, only valid for IPv44.10.0
vmNicUuidStringVM NIC UUID4.10.0
createDateTimestampCreation time4.10.0
lastOpDateTimestampLast modification time4.10.0

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource2.2
nameStringResource name2.2
descriptionStringResource description2.2
primaryStorageUuidStringData Storage UUID2.2
vmInstanceUuidStringVirtual Machine UUID2.2
diskOfferingUuidStringDisk Offering UUID2.2
rootImageUuidString 2.2
installPathString 2.2
typeString 2.2
formatString 2.2
sizeLong 2.2
actualSizeLong 2.2
deviceIdInteger 2.2
stateString 2.2
statusString 2.2
createDateTimestampCreation time2.2
lastOpDateTimestampLast modification time2.2
isShareableBoolean 2.2
volumeQosString 2.2
lastDetachDateTimestamp 2.2
lastVmInstanceUuidString 2.2

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource3.17.13
vmInstanceUuidStringVirtual Machine UUID3.17.13
deviceIdInteger 3.17.13
isoUuidString 3.17.13
isoInstallPathString 3.17.13
nameStringResource name3.17.13
descriptionStringResource description3.17.13
createDateTimestampCreation time3.17.13
lastOpDateTimestampLast modification time3.17.13

SDK Examples

Java SDK

ChangeVmImageAction action = new ChangeVmImageAction();
action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488";
action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmImageAction.Result res = action.call();

Python SDK

action = ChangeVmImageAction()
action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488"
action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()