Configure IP on Physical Interface

POST/zstack/v1/hosts/nics/{interfaceUuid}/ip

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "ipAddress": "1.1.1.1",
    "netmask": "255.255.0.0"
  },
  "systemTags": [],
  "userTags": []
}

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

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"ipAddress":"1.1.1.1","netmask":"255.255.0.0"}}' http://localhost:8080/zstack/v1/hosts/nics/d50ade48aec73edc87b0f7c2d6a84bcc/ip

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
interfaceUuidStringurlPhysical NIC UUID 4.7.0
ipAddress (optional)Stringbody (contained in params structure)IP address 4.7.0
netmask (optional)Stringbody (contained in params structure)Subnet mask 4.7.0
isDefaultRoute (optional)Booleanbody (contained in params structure)Whether to set as default route 4.7.0
systemTags (optional)ListbodySystem tag 4.7.0
userTags (optional)ListbodyUser tag 4.7.0

API Response

Response Example

{
  "inventory": {
    "hostUuid": "d7fd94874d4235439abe33e041dd0928",
    "ipAddresses": [
      "192.168.1.1"
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 4.7.0
inventoryHostNetworkInterfaceInventorySee details inventory4.7.0
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See details error4.7.0

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.7.0
hostUuidStringHost UUID4.7.0
bondingUuidStringBond UUID4.7.0
interfaceNameStringNIC name4.7.0
interfaceTypeStringNIC usage state, can be nomaster, bridgeSlave, bondSlave4.7.0
speedLongNIC speed4.7.0
slaveActiveBooleanBond link status4.7.0
carrierActiveBooleanPhysical link status4.7.0
ipAddressesListIP addresses4.7.0
gatewayStringGateway address4.7.0
macStringMAC address4.7.0
callBackIpStringCallback address4.7.0
pciDeviceAddressStringNIC PCI address4.7.0
offloadStatusString 4.7.0
descriptionStringResource description4.7.0
createDateTimestampCreation time4.7.0
lastOpDateTimestampLast modification time4.7.0

error

NameTypeDescriptionStarting Version
codeStringError code number, globally unique identifier of the error, e.g. SYS.1000, HOST.10014.7.0
descriptionStringBrief description of the error4.7.0
detailsStringDetailed error information4.7.0
elaborationStringReserved field, default is null4.7.0
opaqueLinkedHashMapReserved field, default is null4.7.0
causeErrorCodeRoot cause, the error that caused the current error. If there is no original error, this field is null4.7.0

SDK Examples

Java SDK

SetIpOnHostNetworkInterfaceAction action = new SetIpOnHostNetworkInterfaceAction();
action.interfaceUuid = "d50ade48aec73edc87b0f7c2d6a84bcc";
action.ipAddress = "1.1.1.1";
action.netmask = "255.255.0.0";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetIpOnHostNetworkInterfaceAction.Result res = action.call();

Python SDK

SetIpOnHostNetworkInterfaceAction action = SetIpOnHostNetworkInterfaceAction()
action.interfaceUuid = "d50ade48aec73edc87b0f7c2d6a84bcc"
action.ipAddress = "1.1.1.1"
action.netmask = "255.255.0.0"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetIpOnHostNetworkInterfaceAction.Result res = action.call()