SetVmStaticIp
API Request
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actionsHeaders
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.
{
"setVmStaticIp": {
"l3NetworkUuid": "61e66d487dff454f9509a1f19606d274",
"ip": "192.168.10.10"
},
"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 PUT -d '{"setVmStaticIp":{"l3NetworkUuid":"9fcbd78edb58391f8d9b879ea87598fd","ip":"192.168.10.10"}}' http://localhost:8080/zstack/v1/vm-instances/e3749802228a36038d0e17041414fd17/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 0.6 | |
| l3NetworkUuid | String | body (contained in the setVmStaticIp structure) | The L3 network UUID. | 0.6 | |
| ip | String | body (contained in the setVmStaticIp structure) | Optional. The specified IP address. | 4.6.21 | |
| ip6 | String | body (contained in the setVmStaticIp structure) | Optional. The specified IPv6 address. | 3.10.0 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 | |
| netmask | String | body (contained in the setVmStaticIpstructure) | Optional. The IPv4 netmask. | 4.6.21 | |
| gateway | String | body (contained in the setVmStaticIpstructure) | Optional. The IPv4 gateway. | 4.6.21 | |
| ipv6Gateway | String | body (contained in the setVmStaticIpstructure) | Optional. The IPv6 gateway. | 4.6.21 | |
| ipv6Prefix | String | body (contained in the setVmStaticIpstructure) | Optional. The IPv6 prefix. | 4.6.21 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
SetVmStaticIpAction action = new SetVmStaticIpAction();
action.vmInstanceUuid = "e3749802228a36038d0e17041414fd17";
action.l3NetworkUuid = "9fcbd78edb58391f8d9b879ea87598fd";
action.ip = "192.168.10.10";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVmStaticIpAction.Result res = action.call();Python
SDK
SetVmStaticIpAction action = SetVmStaticIpAction()
action.vmInstanceUuid = "e3749802228a36038d0e17041414fd17"
action.l3NetworkUuid = "9fcbd78edb58391f8d9b879ea87598fd"
action.ip = "192.168.10.10"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetVmStaticIpAction.Result res = action.call()