AddVmNicToLoadBalancer

API Request

URLs
POST zstack/v1/load-balancers/listeners/{listenerUuid}/vm-instances/nics
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"vmNicUuids": [
"aadbfdd8413545d9a1d53d8a0cfa58a8"
    ]
  },
"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 47ac995879a9490f83b6b6ef79bca99f" \
-X POST -d '{"params":{"vmNicUuids":["f141d926d13b34cc905507ce7aa9a479"]}}' \
http://localhost:8080/zstack/v1/load-balancers/listeners/21e488793c5831a0842d72a63bcdaf04/vm-instances/nics
Request Parameters
Name Type Location Description Optional Value Starting Version
vmNicUuids List body (contained in the params structure) The VM NIC UUIDs. 0.6
listenerUuid String url The UUID of the load balancer listener. 0.6
systemTags List body Optional. The system tags. 0.6
userTags List body Optional. The user tags. 0.6
Note:
  • When you add a VM NIC to a load balancer in ZStack Cloud, you can set the weight of the backend server by adding the balancerWeight option to SystemTags.
    • Format of the balancerWeight option: balancerWeight::{nicUuid}::{weight}. Here, weight is the weight of the backend server. Weight range: 0-100, integer. Default value: 100.
    • Example: balancerWeight::{"c44007641c9040c6b2587e19b1b3e2b0"}::{100}

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
AddVmNicToLoadBalancerAction action = new AddVmNicToLoadBalancerAction();
action.vmNicUuids = asList("01741d3cc9d0422197b2176f3c977d52");
action.listenerUuid = "fd774b08700545ddaa5938fb2ccf4320";
action.sessionId = "ed5ea413b2354a94ac7b427528f88d26";
AddVmNicToLoadBalancerAction.Result res = action.call()
Python SDK
AddVmNicToLoadBalancerAction action = AddVmNicToLoadBalancerAction()
action.vmNicUuids = [9b08b7603be945d2928a08a0e8d1fc00]
action.listenerUuid = "874bcad239a645af8cd69ed267a48809"
action.sessionId = "a70b5f9862424ceb8ea8e2c7d679e0df"
AddVmNicToLoadBalancerAction.Result res = action.call()