VM Related Interfaces

Register a VM Instance from Metadata

POST/zstack/v1/vm-instances/metadata/register

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "metadataPath": "/mnt/ps/vm-metadata/ff01ec80fd11327cba7519b66119d900.vmmeta",
    "primaryStorageUuid": "ff0359abb8443d2f8077cc368afa7c00",
    "zoneUuid": "ff0c268342c535aabf273d41a2be1d00",
    "clusterUuid": "ff0bcb94de7a3567b641d3fde2329d00",
    "hostUuid": "ff0192fa70113da886101145c084bd00",
    "name": "my-restored-vm"
  },
  "systemTags": [],
  "userTags": []
}

In the preceding example, the systemTags and userTags fields can be omitted. They are listed to indicate that the body can include these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"metadataPath":"/mnt/ps/vm-metadata/ff01ec80fd11327cba7519b66119d900.vmmeta","primaryStorageUuid":"ff0359abb8443d2f8077cc368afa7c00","zoneUuid":"ff0c268342c535aabf273d41a2be1d00","clusterUuid":"ff0bcb94de7a3567b641d3fde2329d00","hostUuid":"ff0192fa70113da886101145c084bd00","name":"my-restored-vm"}}' \
http://localhost:8080/zstack/v1/vm-instances/metadata/register

Parameters

NameTypeLocationDescriptionOptional ValuesSince
metadataPathStringbody (contained in the params structure)Path of the metadata file on primary storage 5.0.0
primaryStorageUuidStringbody (contained in the params structure)Target primary storage UUID 5.0.0
zoneUuidStringbody (contained in the params structure)Zone UUID 5.0.0
clusterUuidStringbody (contained in the params structure)Cluster UUID 5.0.0
hostUuid (Optional)Stringbody (contained in the params structure)Host UUID 5.0.0
name (Optional)Stringbody (contained in the params structure)VM instance name 5.0.0
tagUuids (Optional)Listbody (contained in the params structure)List of tag UUIDs 5.0.0
systemTags (Optional)ListbodySystem tags 5.0.0
userTags (Optional)ListbodyUser tags 5.0.0

API Response

Response Example

{
  "inventory": {
    "uuid": "21d608564fe438fd8b6c29fde66a4881",
    "name": "recovered-vm"
  }
}
NameTypeDescriptionSince
successbooleanWhether the operation succeeded5.0.0
inventoryVmInstanceInventoryFor details, see inventory5.0.0
errorErrorCodeFor details, see error5.0.0

inventory

NameTypeDescriptionSince
uuidStringResource UUID, which uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
zoneUuidStringZone UUID0.6
clusterUuidStringCluster UUID0.6
imageUuidStringImage UUID0.6
hostUuidStringHost UUID0.6
lastHostUuidStringHost UUID used for the last startup0.6
instanceOfferingUuidStringInstance offering UUID. This field is deprecated.0.6
rootVolumeUuidStringRoot volume UUID0.6
platformStringVM instance platform, such as Windows, Linux, or another platform0.6
architectureStringVM instance architecture, such as x86_64, aarch64, or another architecture0.6
defaultL3NetworkUuidStringDefault distributed port group UUID0.6
typeStringVM instance type, indicating whether the VM instance is used by a user or for special platform purposes0.6
hypervisorTypeStringVM instance hypervisor type, usually KVM0.6
memorySizeLongMemory size0.6
cpuNumIntegerNumber of CPUs0.6
cpuSpeedLongCPU speed0.6
allocatorStrategyStringVM instance allocation strategy0.6
createDateTimestampCreation time0.6
lastOpDateTimestampLast modification time0.6
stateStringStatus indicating whether the VM instance is enabled0.6
guestOsTypeStringGuest operating system type of the VM instance3.11.2
vmNicsListFor details, see vmNics0.6
allVolumesListFor details, see allVolumes0.6
vmCdRomsListFor details, see vmCdRoms0.6

vmNics

NameTypeDescriptionSince
uuidStringResource UUID, which uniquely identifies the resource3.17.13
vmInstanceUuidStringVM instance UUID3.17.13
l3NetworkUuidStringDistributed port group UUID3.17.13
ipString 3.17.13
macString 3.17.13
hypervisorTypeString 3.17.13
netmaskString 3.17.13
gatewayString 3.17.13
metaDataString 3.17.13
ipVersionInteger 3.17.13
driverTypeString 3.17.13
internalNameString 3.17.13
deviceIdInteger 3.17.13
typeString 3.17.13
stateStringNIC state3.17.13
createDateTimestampCreation time3.17.13
lastOpDateTimestampLast modification time3.17.13
usedIpsListFor details, see usedIps3.17.13

usedIps

NameTypeDescriptionSince
uuidStringResource UUID, which 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 as a Long value. This field is valid only for IPv4.4.10.0
vmNicUuidStringVM NIC UUID4.10.0
createDateTimestampCreation time4.10.0
lastOpDateTimestampLast modification time4.10.0

allVolumes

NameTypeDescriptionSince
uuidStringResource UUID, which uniquely identifies the resource3.17.13
nameStringResource name3.17.13
descriptionStringDetailed description of the resource3.17.13
primaryStorageUuidStringPrimary storage UUID3.17.13
vmInstanceUuidStringVM instance UUID3.17.13
diskOfferingUuidStringDisk offering UUID3.17.13
rootImageUuidString 3.17.13
installPathString 3.17.13
typeString 3.17.13
formatString 3.17.13
sizeLong 3.17.13
actualSizeLong 3.17.13
deviceIdInteger 3.17.13
stateString 3.17.13
statusString 3.17.13
createDateTimestampCreation time3.17.13
lastOpDateTimestampLast modification time3.17.13
isShareableBoolean 3.17.13
volumeQosString 3.17.13
lastDetachDateTimestamp 3.17.13
lastVmInstanceUuidString 3.17.13

vmCdRoms

NameTypeDescriptionSince
uuidStringResource UUID, which uniquely identifies the resource3.17.13
vmInstanceUuidStringVM instance UUID3.17.13
deviceIdInteger 3.17.13
isoUuidString 3.17.13
isoInstallPathString 3.17.13
nameStringResource name3.17.13
descriptionStringDetailed description of the resource3.17.13
createDateTimestampCreation time3.17.13
lastOpDateTimestampLast modification time3.17.13

error

NameTypeDescriptionSince
codeStringError code, which is the globally unique identifier of the error, such as SYS.1000 or HOST.10010.6
descriptionStringSummary description of the error0.6
detailsStringDetailed information about the error0.6
elaborationStringReserved field. The default value is null.0.6
opaqueLinkedHashMapReserved field. The default value is null.0.6
causeErrorCodeRoot error that caused the current error. If there is no original error, this field is null.0.6

SDK Example

Java SDK

RegisterVmInstanceFromMetadataAction action = new RegisterVmInstanceFromMetadataAction();
action.metadataPath = "/mnt/ps/vm-metadata/ff01ec80fd11327cba7519b66119d900.vmmeta";
action.primaryStorageUuid = "ff0359abb8443d2f8077cc368afa7c00";
action.zoneUuid = "ff0c268342c535aabf273d41a2be1d00";
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00";
action.hostUuid = "ff0192fa70113da886101145c084bd00";
action.name = "my-restored-vm";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RegisterVmInstanceFromMetadataAction.Result res = action.call();

Python SDK

action = RegisterVmInstanceFromMetadataAction()
action.metadataPath = "/mnt/ps/vm-metadata/ff01ec80fd11327cba7519b66119d900.vmmeta"
action.primaryStorageUuid = "ff0359abb8443d2f8077cc368afa7c00"
action.zoneUuid = "ff0c268342c535aabf273d41a2be1d00"
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00"
action.hostUuid = "ff0192fa70113da886101145c084bd00"
action.name = "my-restored-vm"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()