Forum Discussion
How to add members to a pool - ControlRestAPI
Seems like we can only add one pool member per POST /mgmt/tm/ltm/pool/<poolName>/members call.
This works (adding "CentOS-internal20:8080" to the pool "Pool-CentOS80").
$ curl -sku $PASS https://$HOST/mgmt/tm/ltm/pool/Pool-CentOS80/members \
-X POST -H "Content-type: application/json" \
-d '{"name":"CentOS-internal20:8080", "partition":"Common"}'
But this does not (note: the JSON text in the -d option is verified valid).
$ curl -sku $PASS https://$HOST/mgmt/tm/ltm/pool/Pool-CentOS80/members \
-X POST -H "Content-type: application/json" \
-d '[{"name":"CentOS-internal20:8080", "partition":"Common"}, {"name":"CentOS-internal20:8081", "partition":"Common"}]'
{"code":400,"message":"Found invalid JSON body in the request....
So you need to call the POST multiple times.
An alternative way is to overwrite the existing pool members by PATCHing the pool itself (PATCH /mgmt/tm/ltm/pool/<pool>).
For example, my pool "Pool-CentOS80" has two members: "CentOS-internal20:80" and "CentOS-internal30:80". e.g.,
$ curl -sku $PASS https://$HOST/mgmt/tm/ltm/pool/Pool-CentOS80?expandSubcollections=true \
| jq -r '.membersReference.items[].name'
CentOS-internal20:80
CentOS-internal30:80
(for readability sake, only pool member names are extracted using jq).
To add "CentOS-internal20:8080" and "CentOS-internal20:8081" to the pool, PATCH it with the "four" pool members: e.g.,
$ curl -sku $PASS https://$HOST/mgmt/tm/ltm/pool/Pool-CentOS80 \
-X PATCH -H "Content-type: application/json" -d '{
"membersReference": {
"items": [
{"name":"CentOS-internal20:80", "partition":"Common"}, // exiting one
{"name":"CentOS-internal30:80", "partition":"Common"}, // exiting one
{"name":"CentOS-internal20:8080", "partition":"Common"}, // new
{"name": "CentOS-internal20:8081", "partition":"Common"} // new
]
}
}'
(the payload part is formatted with comments by hand for readability (note: No comment allowed in a JSON text)).
Now I have four.
$ curl -sku $PASS https://$HOST/mgmt/tm/ltm/pool/Pool-CentOS80?expandSubcollections=true \
| jq -r '.membersReference.items[].name'
CentOS-internal20:80
CentOS-internal20:8080
CentOS-internal20:8081
CentOS-internal30:80
I hope this helps.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com