SetIpOnHostNetworkInterface
API Request
URLs
POST zstack/v1/hosts/nics/{interfaceUuid}/ipHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"ipAddress": "1.1.1.1",
"netmask": "255.255.0.0"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
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/ipRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| interfaceUuid | String | url | The physical NIC port UUID. | 4.7.0 | |
| Optional. The user tags. | String | body (contained in the params structure) | Optional. The IP address. | 4.7.0 | |
| Optional. The user tags. | String | body (contained in the params structure) | Optional. The netmask. | 4.7.0 | |
| Optional. The user tags. | Boolean | body (contained in the params structure) | Optional. Whether to set a default route. | 4.7.0 | |
| Optional. The user tags. | List | body | Optional. The system tags. | 4.7.0 | |
| Optional. The user tags. | List | body | Optional. The user tags. | 4.7.0 |
API Response
Sample
Response
{
"inventory": {
"hostUuid": "d7fd94874d4235439abe33e041dd0928",
"ipAddresses": [
"192.168.1.1"
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.7.0 | |
| inventory | HostNetworkInterfaceInventory | See inventory. | 4.7.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, seeerror. | 4.7.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.0 |
| hostUuid | String | The host UUID. | 4.7.0 |
| bondingUuid | String | The bond UUID. | 4.7.0 |
| interfaceName | String | The NIC name. | 4.7.0 |
| interfaceType | String | The NIC type. Options: nomaster, bridgeSlave, and bondSlave. | 4.7.0 |
| speed | Long | The NIC speed. | 4.7.0 |
| slaveActive | Boolean | The bond link status. | 4.7.0 |
| carrierActive | Boolean | The physical link status. | 4.7.0 |
| ipAddresses | List | The IP address. | 4.7.0 |
| gateway | String | The gateway address. | 4.7.0 |
| mac | String | The MAC address. | 4.7.0 |
| callBackIp | String | The callback IP address. | 4.7.0 |
| pciDeviceAddress | String | The PCI address of the interface. | 4.7.0 |
| offloadStatus | String | 4.7.0 | |
| description | String | The resource description. | 4.7.0 |
| createDate | Timestamp | The creation time. | 4.7.0 |
| lastOpDate | Timestamp | The last operation time. | 4.7.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 4.7.0 |
| description | String | The brief description of the error. | 4.7.0 |
| details | String | The details about the error. | 4.7.0 |
| elaboration | String | The reserved field. Default value: null. | 4.7.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 4.7.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 4.7.0 |
SDK Sample
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()