VM Related Interfaces

Update VM Information

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

Headers

Authorization: OAuth the-session-uuid

Body

{
  "updateVmInstance": {
    "name": "new vm name"
  },
  "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 '{"updateVmInstance":{"name":"new vm name"}}' \
http://localhost:8080/zstack/v1/vm-instances/dfa2feae60f431ac8d5f071f5594cfc1/actions

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

uuid

String

url

Virtual Machine UUID

 

0.6

name (Optional)

String

body (contained in updateVmInstance structure)

Virtual Machine name

 

0.6

description (Optional)

String

body (contained in updateVmInstance structure)

Virtual Machine description

 

0.6

state (Optional)

String

body (contained in updateVmInstance structure)

Virtual Machine state- In general, the Virtual Machine state should not be updated directly; otherwise, the virtualization platform may misjudge the state of the Virtual Machine.

  • This field should only be used when the actual state of the Virtual Machine is inconsistent with the state recorded by the virtualization platform, and the synchronization mechanism of the virtualization platform has failed (usually meaning a bug).
  • Administrators should fully understand the consequences of using this field.
  • Stopped
  • Running

0.6

defaultL3NetworkUuid (Optional)

String

body (contained in updateVmInstance structure)

Default L3 Network UUID

 

0.6

platform (Optional)

String

body (contained in updateVmInstance structure)

Virtual Machine platform type

  • Linux
  • Windows
  • WindowsVirtio
  • Other
  • Paravirtualization

0.6

cpuNum (Optional)

Integer

body (contained in updateVmInstance structure)

  • Virtual Machine CPU count. Takes effect after stopping/starting the Virtual Machine
  • For Virtual Machines created when the system parameter NUMA is true, supports dynamic adjustment

 

0.6

memorySize (Optional)

Long

body (contained in updateVmInstance structure)

  • Virtual Machine memory size. Takes effect after stopping/starting the Virtual Machine
  • For Virtual Machines created when the system parameter NUMA is true, supports dynamic adjustment.

 

0.6

guestOsType (Optional)

String

body (contained in updateVmInstance structure)

 

 

4.1.0

reservedMemorySize (Optional)

Long

body (contained in updateVmInstance structure)

 

 

4.7.21

systemTags (Optional)

List

body

System Tag

 

0.6

userTags (Optional)

List

body

User Tag

 

0.6

API Response

Response Example

{
  "inventory": {
    "uuid": "6710cdffb0653455809b6511a6b3aaa4",
    "name": "new vm name",
    "description": "web server VM",
    "zoneUuid": "aa63c5a3b3c436fa94e5e851f057fe23",
    "clusterUuid": "48b424d94ed239f1b18e1ce37db24cf8",
    "imageUuid": "4e1ac550da8d30c7b07162acc39773c1",
    "hostUuid": "1f3ffea4673e3e4197681ee030d1794b",
    "lastHostUuid": "d334dadb7cfc34da8f6f7d74dfd04692",
    "instanceOfferingUuid": "33b38aff5cbe3e24a9266300f7163d20",
    "rootVolumeUuid": "761df8e1eef933ee8d7f3b7f8551b754",
    "platform": "Linux",
    "defaultL3NetworkUuid": "3a3c91f4a28a31beb410d6d1c3dc862c",
    "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": "ae19167e24713aeea9c45e6f2d27249d",
        "vmInstanceUuid": "6710cdffb0653455809b6511a6b3aaa4",
        "usedIpUuid": "010f4817011b32d3b476faa3f393d765",
        "l3NetworkUuid": "3a3c91f4a28a31beb410d6d1c3dc862c",
        "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": "761df8e1eef933ee8d7f3b7f8551b754",
        "name": "Root-Volume-For-VM-6710cdffb0653455809b6511a6b3aaa4",
        "primaryStorageUuid": "da81ed018a9738ff97a16d7b7a43327d",
        "vmInstanceUuid": "6710cdffb0653455809b6511a6b3aaa4",
        "diskOfferingUuid": "bd9b406d36c13fc7ad3f995535415898",
        "rootImageUuid": "4e1ac550da8d30c7b07162acc39773c1",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-761df8e1eef933ee8d7f3b7f8551b754/761df8e1eef933ee8d7f3b7f8551b754.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"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed. When the operation succeeds, this field is null. For details, see error0.6
inventoryVmInstanceInventoryFor details, see inventory0.6

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier of the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause. The error that triggered the current error. If there is no original error, this field is null0.6

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringResource description0.6
zoneUuidStringData Center UUID0.6
clusterUuidStringCluster UUID0.6
imageUuidStringImage UUID0.6
hostUuidStringHost UUID0.6
lastHostUuidString 0.6
instanceOfferingUuidStringInstance Offering UUID0.6
rootVolumeUuidStringRoot Volume UUID0.6
platformString 0.6
architectureString 0.6
defaultL3NetworkUuidString 0.6
typeString 0.6
hypervisorTypeString 0.6
memorySizeLong 0.6
cpuNumInteger 0.6
cpuSpeedLong 0.6
allocatorStrategyString 0.6
createDateTimestampCreate time0.6
lastOpDateTimestampLast update time0.6
stateString 0.6
guestOsTypeString 4.1.2
vmNicsListFor details, see vmNics0.6
allVolumesListFor details, see allVolumes0.6
vmCdRomsListFor details, see vmCdRoms0.6

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
vmInstanceUuidStringVirtual Machine UUID0.6
l3NetworkUuidStringL3 Network UUID0.6
ipStringIP address4.1.0
macStringMAC address4.1.0
hypervisorTypeStringHypervisor type4.1.0
netmaskStringNetmask4.1.0
gatewayStringGateway4.1.0
metaDataString 0.6
ipVersionIntegerIP address version3.1.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdIntegerDevice ID0.6
typeStringNIC type4.1.0
createDateTimestampCreate time0.6
lastOpDateTimestampLast update time0.6
usedIpsListFor details, see usedIps0.6

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
ipRangeUuidStringIP Range UUID0.6
l3NetworkUuidStringL3 Network UUID0.6
ipVersionIntegerIP protocol version3.1.0
ipStringIP address0.6
netmaskStringNetwork mask0.6
gatewayStringGateway address0.6
usedForString 0.6
ipInLonglong 0.6
vmNicUuidStringVirtual Machine NIC UUID3.1.0
createDateTimestampCreate time0.6
lastOpDateTimestampLast update time0.6

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringResource description0.6
primaryStorageUuidStringPrimary Storage UUID0.6
vmInstanceUuidStringVirtual Machine UUID0.6
diskOfferingUuidStringDisk Offering UUID0.6
rootImageUuidStringRoot Image UUID4.1.0
installPathStringVolume install path on Primary Storage4.1.0
typeStringVolume type, data volume/root volume4.1.0
formatStringVolume format4.1.0
sizeLongVolume size4.1.0
actualSizeLongActual volume size4.1.0
deviceIdInteger 0.6
stateStringWhether the volume is enabled4.1.0
statusStringVolume status4.1.0
createDateTimestampCreate time0.6
lastOpDateTimestampLast update time0.6
isShareableBoolean 0.6
volumeQosString 4.7.13
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.7.13
vmInstanceUuidStringVirtual Machine UUID4.7.13
deviceIdInteger 4.7.13
isoUuidString 4.7.13
isoInstallPathString 4.7.13
nameStringResource name4.7.13
descriptionStringResource description4.7.13
createDateTimestampCreate time4.7.13
lastOpDateTimestampLast update time4.7.13

SDK Examples

Java SDK

UpdateVmInstanceAction action = new UpdateVmInstanceAction();
action.uuid = "dfa2feae60f431ac8d5f071f5594cfc1";
action.name = "new vm name";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVmInstanceAction.Result res = action.call();

Python SDK

action = UpdateVmInstanceAction()
action.uuid = "dfa2feae60f431ac8d5f071f5594cfc1"
action.name = "new vm name"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()