VM Related Interfaces

Change Virtual Machine NIC L3 Network

POST/zstack/v1/vm-instances/nics/{vmNicUuid}/l3-networks/{destL3NetworkUuid}

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/nics/1183a0462aa83243a659ff91326888fb/l3-networks/e46ab07103763f0dbd3e99af2e3be4b0

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmNicUuidStringurlVirtual Machine NIC UUID 4.1.0
destL3NetworkUuidStringurl  4.1.0
systemTags (Optional)ListbodySystem Tag 4.1.0
userTags (Optional)ListbodyUser Tag 4.1.0
staticIp (Optional)Stringbody (contained in params structure)  0.6
vmNicParams (Optional)Stringbody (contained in params structure)NIC information 4.2.0

API Response

Response Example

{
  "inventory": {
    "uuid": "9d4cdab9192b3de3b2495b1e326910c7",
    "vmInstanceUuid": "0ae9a1992fb436a58e820bdcb4dd17c4",
    "usedIpUuid": "c0c5860c05ce3e70b14b4f501fedff71",
    "l3NetworkUuid": "9390346b3a8a3c829b05dbe30569390a",
    "ip": "192.168.1.10",
    "mac": "00:0c:29:bd:99:fc",
    "netmask": "255.255.255.0",
    "gateway": "192.168.1.1",
    "deviceId": 0
  }
}
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.1.0
inventoryVmNicInventoryFor details, see inventory4.1.0

error

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

inventory

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

usedIps

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

SDK Examples

Java SDK

ChangeVmNicNetworkAction action = new ChangeVmNicNetworkAction();
action.vmNicUuid = "1183a0462aa83243a659ff91326888fb";
action.destL3NetworkUuid = "e46ab07103763f0dbd3e99af2e3be4b0";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmNicNetworkAction.Result res = action.call();

Python SDK

action = ChangeVmNicNetworkAction()
action.vmNicUuid = "1183a0462aa83243a659ff91326888fb"
action.destL3NetworkUuid = "e46ab07103763f0dbd3e99af2e3be4b0"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()