VM Related Interfaces

Create VM Nic

POST/zstack/v1/nics

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "l3NetworkUuid": "cbb5d7cd7f51332cb18c124ea430863f"
  },
  "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":{"l3NetworkUuid":"cbb5d7cd7f51332cb18c124ea430863f"}}' http://localhost:8080/zstack/v1/nics

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
l3NetworkUuidStringbody(contained in params structure)Distributed Port Group UUID 4.0.0
ip (optional)Stringbody(contained in params structure)  4.0.0
resourceUuid (optional)Stringbody(contained in params structure)  4.0.0
systemTags (optional)ListbodySystem Tags 4.0.0
userTags (optional)ListbodyUser Tags 4.0.0
tagUuids (optional)Listbody(contained in params structure)Tag UUID List 3.4.0

API Response

Return Example

{
  "inventory": {
    "uuid": "158c432596ab3418bbdd04583541d42d",
    "usedIpUuid": "acfdb23e1b0e39e48b10ee02d10ed74f",
    "l3NetworkUuid": "a1791966d2fd375bbb469dd0308d3be6",
    "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"
  }
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. 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 triggered the current error. If there is no original error, this field is null4.0.0

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, a unique identifier for the resource4.0.0
vmInstanceUuidStringVirtual Machine UUID4.0.0
l3NetworkUuidStringDistributed Port Group UUID4.0.0
ipStringIP Address4.0.0
macStringMAC Address4.0.0
hypervisorTypeStringVirtualization 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 Status4.7.13
createDateTimestampCreation Time4.0.0
lastOpDateTimestampLast Operation Date4.0.0
usedIpsListFor details, see usedIps4.0.0

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID, a unique identifier for 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
vmNicUuidStringVM NIC UUID4.0.0
createDateTimestampCreation Time4.0.0
lastOpDateTimestampLast Operation Date4.0.0

SDK Examples

Java SDK

CreateVmNicAction action = new CreateVmNicAction();
action.l3NetworkUuid = "cbb5d7cd7f51332cb18c124ea430863f";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmNicAction.Result res = action.call();

Python SDK

action = CreateVmNicAction()
action.l3NetworkUuid = "cbb5d7cd7f51332cb18c124ea430863f"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()