Forum Discussion
Modifying Pool Members through REST API
I'm currently modifying our script that we use to manage our LTM boxes, specifically the part that modifies and creates nodes and pools. Historically we've had the script run a variety of SSH commands using TMSH as we were not very fond of the SOAP API. However with the new REST API we're starting to convert everything over. One of the issues I've run into is how to add new members to a pool.
In TMSH, if a pool already has members you can just add new ones to the pool. However, with the REST API it seems that the only way to modify pool members is to use a PUT command with a new collection of members. This automatically overrides the existing collection of pool members with the new collection. While it's definitely possible to pull down the existing pool and then tack on the new member, this seems inefficient as it requires two calls. Is there any way to just add members to the pool with the REST API without having to replace the existing collection?
2 Replies
- nitass
Employee
can you try something like this?
rest call [root@ve11d:Active:Changes Pending] config curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo/members | /var/tmp/jq . { "kind": "tm:ltm:pool:members:memberscollectionstate", "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members?ver=11.6.0", "items": [ { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.101:80", "partition": "Common", "fullPath": "/Common/200.200.200.101:80", "generation": 1, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.101:80?ver=11.6.0", "address": "200.200.200.101", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" } ] } [root@ve11d:Active:Changes Pending] config curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo/members -X POST -H "Content-Type: application/json" -d '{"name":"200.200.200.111:80"}' | /var/tmp/jq . { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.111:80", "fullPath": "200.200.200.111:80", "generation": 9, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/200.200.200.111:80?ver=11.6.0" } [root@ve11d:Active:Changes Pending] config curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo/members | /var/tmp/jq . { "kind": "tm:ltm:pool:members:memberscollectionstate", "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members?ver=11.6.0", "items": [ { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.101:80", "partition": "Common", "fullPath": "/Common/200.200.200.101:80", "generation": 1, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.101:80?ver=11.6.0", "address": "200.200.200.101", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" }, { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.111:80", "partition": "Common", "fullPath": "/Common/200.200.200.111:80", "generation": 9, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.111:80?ver=11.6.0", "address": "200.200.200.111", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" } ] } tmsh [root@ve11d:Active:Changes Pending] config tmsh list ltm pool foo ltm pool foo { members { 200.200.200.101:80 { address 200.200.200.101 } 200.200.200.111:80 { address 200.200.200.111 } } } - nitass
Employee
I was wondering if it were possible to send an array of members as opposed to adding one at a time.
i might be wrong but i think we have to send to pool url (instead of members url); however, as you know, it will overwrite the members list.
[root@ve11c:Active:In Sync] images curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo/members | /var/tmp/jq . { "kind": "tm:ltm:pool:members:memberscollectionstate", "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members?ver=11.6.0", "items": [ { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.101:80", "partition": "Common", "fullPath": "/Common/200.200.200.101:80", "generation": 9, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.101:80?ver=11.6.0", "address": "200.200.200.101", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" } ] } [root@ve11c:Active:In Sync] images curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo -H "Content-Type: application/json" -X PUT -d '{"members":[{"name":"200.200.200.111:80"},{"name":"200.200.200.102:80"}]}' | /var/tmp/jq . { "kind": "tm:ltm:pool:poolstate", "name": "foo", "fullPath": "foo", "generation": 10, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo?ver=11.6.0", "allowNat": "yes", "allowSnat": "yes", "ignorePersistedWeight": "disabled", "ipTosToClient": "pass-through", "ipTosToServer": "pass-through", "linkQosToClient": "pass-through", "linkQosToServer": "pass-through", "loadBalancingMode": "round-robin", "minActiveMembers": 0, "minUpMembers": 0, "minUpMembersAction": "failover", "minUpMembersChecking": "disabled", "queueDepthLimit": 0, "queueOnConnectionLimit": "disabled", "queueTimeLimit": 0, "reselectTries": 0, "serviceDownAction": "none", "slowRampTime": 10, "membersReference": { "link": "https://localhost/mgmt/tm/ltm/pool/~Common~foo/members?ver=11.6.0", "isSubcollection": true } } [root@ve11c:Active:Not All Devices Synced] images curl -sk -u admin:admin https://localhost/mgmt/tm/ltm/pool/foo/members | /var/tmp/jq . { "kind": "tm:ltm:pool:members:memberscollectionstate", "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members?ver=11.6.0", "items": [ { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.102:80", "partition": "Common", "fullPath": "/Common/200.200.200.102:80", "generation": 10, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.102:80?ver=11.6.0", "address": "200.200.200.102", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" }, { "kind": "tm:ltm:pool:members:membersstate", "name": "200.200.200.111:80", "partition": "Common", "fullPath": "/Common/200.200.200.111:80", "generation": 10, "selfLink": "https://localhost/mgmt/tm/ltm/pool/foo/members/~Common~200.200.200.111:80?ver=11.6.0", "address": "200.200.200.111", "connectionLimit": 0, "dynamicRatio": 1, "ephemeral": "false", "fqdn": { "autopopulate": "disabled" }, "inheritProfile": "enabled", "logging": "disabled", "monitor": "default", "priorityGroup": 0, "rateLimit": "disabled", "ratio": 1, "session": "user-enabled", "state": "unchecked" } ] } [root@ve11c:Active:In Sync] images tmsh list ltm pool foo ltm pool foo { members { 200.200.200.102:80 { address 200.200.200.102 } 200.200.200.111:80 { address 200.200.200.111 } } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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