VM Related Interfaces

Attach L3 Network to NIC

POST/zstack/v1/nics/{vmNicUuid}/l3-networks/{l3NetworkUuid}

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/nics/573a061841c833f098482a47474a4514/l3-networks/8ad81f74fbf539d98c542fa94ecfa7d9

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmNicUuidStringurlVirtual Machine NIC UUID 3.1.0
l3NetworkUuidStringurlDistributed Port Group UUID 3.1.0
staticIp (Optional)Stringbody (contained in params structure)Specify the IP address to assign to the Virtual Machine 3.1.0
systemTags (Optional)Listbody  3.1.0
userTags (Optional)Listbody  3.1.0

API Response

Response Example

{
  "inventory": {
    "uuid": "243f7b018d8931c0a3098c61a982c4cb",
    "vmInstanceUuid": "1d109154036639d990acd002eda6b353",
    "usedIpUuid": "dc7bd6facfce3d4fa3e713374f574be0",
    "l3NetworkUuid": "a4fd5f8fb7e33b3c92ac0d4c6d96c800",
    "ip": "192.168.1.10",
    "mac": "00:0c:29:bd:99:fc",
    "netmask": "255.255.255.0",
    "gateway": "192.168.1.1",
    "deviceId": 0,
    "state": "enable"
  }
}
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 error3.1.0
inventoryVmNicInventoryFor details, see inventory3.1.0

error

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

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource3.1.0
vmInstanceUuidStringVirtual Machine UUID3.1.0
l3NetworkUuidStringDistributed Port Group UUID3.1.0
ipString 3.1.0
macString 3.1.0
hypervisorTypeString 4.7.13
netmaskString 3.1.0
gatewayString 3.1.0
metaDataString 3.1.0
ipVersionIntegerIP protocol number3.1.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdInteger 3.1.0
typeString 4.7.13
stateStringNIC State4.7.13
createDateTimestampCreate time3.1.0
lastOpDateTimestampLast modification time3.1.0
usedIpsListFor details, see usedIps3.1.0

usedIps

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource3.1.0
ipRangeUuidStringIP Range UUID3.1.0
l3NetworkUuidStringDistributed Port Group UUID3.1.0
ipVersionIntegerIP protocol number3.1.0
ipStringIP address3.1.0
netmaskStringNetwork mask3.1.0
gatewayStringGateway address3.1.0
usedForString 3.1.0
ipInLonglong 3.1.0
vmNicUuidStringVirtual Machine NIC UUID3.1.0
createDateTimestampCreate time3.1.0
lastOpDateTimestampLast modification time3.1.0

SDK Examples

Java SDK

AttachL3NetworkToVmNicAction action = new AttachL3NetworkToVmNicAction();
action.vmNicUuid = "573a061841c833f098482a47474a4514";
action.l3NetworkUuid = "8ad81f74fbf539d98c542fa94ecfa7d9";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachL3NetworkToVmNicAction.Result res = action.call();

Python SDK

action = AttachL3NetworkToVmNicAction()
action.vmNicUuid = "573a061841c833f098482a47474a4514"
action.l3NetworkUuid = "8ad81f74fbf539d98c542fa94ecfa7d9"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()