VM Related Interfaces

Attach NIC to Virtual Machine

POST/zstack/v1/vm-instances/{vmInstanceUuid}/nices/{vmNicUuid}

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {},
  "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 POST -d '{"params":{}}' \
http://localhost:8080/zstack/v1/vm-instances/4fea63520ff63f5f9856acd619add4f5/nices/8b22e01e4bf43b1dab1530d2b362bbc5

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmNicUuidStringurlVirtual Machine NIC UUID 4.0.0
vmInstanceUuidListurlVirtual Machine UUID 4.0.0
systemTags (Optional)ListbodySystem Tag 4.0.0
userTags (Optional)ListbodyUser Tag 4.0.0

API Response

Response Example

{
  "inventory": {
    "uuid": "afbd67886d773a45af9a20071bcb09bb",
    "name": "Test-VM",
    "description": "web server VM",
    "zoneUuid": "4b9ddab3f5f738f1a0161f5cf5f33f5c",
    "clusterUuid": "d7061d85666a380cb3dda4cc7f9f16ee",
    "imageUuid": "179a3412da4a32faa927eae552348907",
    "hostUuid": "6ee062370eee3df58623fa99be0b2ce0",
    "lastHostUuid": "09fdbebbaea73df79b744ad0d4bd7088",
    "instanceOfferingUuid": "6dc0db981e68348e89ac79ed18fa4b24",
    "rootVolumeUuid": "a876397202ac3d1daf9f4ea67e75e13d",
    "platform": "Linux",
    "defaultL3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
    "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": "b9415d324b50301e923a990bf65352d0",
        "vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
        "usedIpUuid": "76a49549cb183d35865276187afb482b",
        "l3NetworkUuid": "3baaf68d632f3e9aa12be139d58d968e",
        "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": "a876397202ac3d1daf9f4ea67e75e13d",
        "name": "Root-Volume-For-VM-afbd67886d773a45af9a20071bcb09bb",
        "primaryStorageUuid": "336625bac9e0326b9a9abc7801ef2c86",
        "vmInstanceUuid": "afbd67886d773a45af9a20071bcb09bb",
        "diskOfferingUuid": "475f8e09aae2389ea6945b46601aa683",
        "rootImageUuid": "179a3412da4a32faa927eae552348907",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-a876397202ac3d1daf9f4ea67e75e13d/a876397202ac3d1daf9f4ea67e75e13d.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. This field is null when the operation is successful. For details, see error4.0.0
inventoryVmInstanceInventoryFor details, see inventory4.0.0

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10014.0.0
descriptionStringBrief description of the error4.0.0
detailsStringDetailed error information4.0.0
elaborationStringReserved field, defaults to null4.0.0
opaqueLinkedHashMapReserved field, defaults to null4.0.0
causeErrorCodeRoot cause. The source error that caused the current error. If there is no original error, this field is null4.0.0

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.0.0
nameStringResource name4.0.0
descriptionStringDetailed description of the resource4.0.0
zoneUuidStringData Center UUID4.0.0
clusterUuidStringCluster UUID4.0.0
imageUuidStringImage UUID4.0.0
hostUuidStringHost UUID4.0.0
lastHostUuidString 4.0.0
instanceOfferingUuidString 4.0.0
rootVolumeUuidStringRoot Disk UUID4.0.0
platformString 4.0.0
architectureString 0.6
defaultL3NetworkUuidString 4.0.0
typeString 4.0.0
hypervisorTypeString 4.0.0
memorySizeLong 4.0.0
cpuNumInteger 4.0.0
cpuSpeedLong 4.0.0
allocatorStrategyString 4.0.0
createDateTimestampCreate time4.0.0
lastOpDateTimestampLast modification time4.0.0
stateString 4.0.0
guestOsTypeString 4.1.2
vmNicsListFor details, see vmNics4.0.0
allVolumesListFor details, see allVolumes4.0.0
vmCdRomsListFor details, see vmCdRoms0.6

vmNics

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.0.0
vmInstanceUuidStringVirtual Machine UUID4.0.0
l3NetworkUuidStringDistributed Port Group UUID4.0.0
ipStringIP address4.0.0
macStringMAC address4.0.0
hypervisorTypeStringHypervisor type4.0.0
netmaskStringSubnet mask4.0.0
gatewayStringGateway4.0.0
metaDataString 4.0.0
ipVersionIntegerIP address version4.0.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdIntegerDevice ID4.0.0
typeStringNIC type4.0.0
stateStringNIC state4.7.13
createDateTimestampCreate time4.0.0
lastOpDateTimestampLast modification time4.0.0
usedIpsListFor details, see usedIps4.0.0

usedIps

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.0.0
ipRangeUuidStringIP Range UUID4.0.0
l3NetworkUuidStringDistributed Port Group UUID4.0.0
ipVersionIntegerIP protocol number4.0.0
ipStringIP address4.0.0
netmaskStringNetwork mask4.0.0
gatewayStringGateway address4.0.0
usedForString 4.0.0
ipInLonglong 4.0.0
vmNicUuidStringVirtual Machine NIC UUID4.0.0
createDateTimestampCreate time4.0.0
lastOpDateTimestampLast modification time4.0.0

allVolumes

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource4.0.0
nameStringResource name4.0.0
descriptionStringDetailed description of the resource4.0.0
primaryStorageUuidStringData Storage UUID4.0.0
vmInstanceUuidStringVirtual Machine UUID4.0.0
diskOfferingUuidStringDisk Offering UUID4.0.0
rootImageUuidStringRoot Image UUID4.0.0
installPathStringDisk path on Data Storage4.0.0
typeStringDisk type, data disk/root disk4.0.0
formatStringDisk format4.0.0
sizeLongDisk size4.0.0
actualSizeLongActual disk size4.0.0
deviceIdInteger 4.0.0
stateStringWhether the disk is enabled4.0.0
statusStringDisk status4.0.0
createDateTimestampCreate time4.0.0
lastOpDateTimestampLast modification time4.0.0
isShareableBooleanWhether it is a shared disk4.0.0
volumeQosStringDisk QoS, format such as total=10485764.0.0
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, 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
descriptionStringDetailed description of the resource4.7.13
createDateTimestampCreate time4.7.13
lastOpDateTimestampLast modification time4.7.13

SDK Examples

Java SDK

AttachVmNicToVmAction action = new AttachVmNicToVmAction();
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5";
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachVmNicToVmAction.Result res = action.call();

Python SDK

action = AttachVmNicToVmAction()
action.vmNicUuid = "8b22e01e4bf43b1dab1530d2b362bbc5"
action.vmInstanceUuid = "4fea63520ff63f5f9856acd619add4f5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()