Forum Discussion
kingikra_210056
Nimbostratus
Jul 13, 2015Change multiple pools in one curl REST API command
Hi,
I have succeeded in executing a curl REST API command to disable/enable members in a specific pool.
Problem is, I have two pools that has different components in our product and I cannot upg...
Kevin_Stewart
Employee
Jul 14, 2015Another option might be to use transactions. All of the commands are committed together as a transaction, such that if any of them fail all of the others are rolled back.
!/bin/bash
USERPASS='admin:password'
create a transaction and return the transaction ID
transid=`curl -sk -u $USERPASS -H 'Accept: application/json' -H 'Content-Type: application/json' https://[mgmt-ip]/mgmt/tm/transaction -d '{}' |awk -F"," '{ print $1 }' |awk -F":" '{ print $2 }'`
disable the first pool's member
curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://[mgmt-ip]/mgmt/tm/ltm/pool/[pool-name] -d '{"name":"[pool-name]","members":[{"name":"[member-name]","state":"user-down"}]}'
disable the second pool's member
curl -sk -u $USERPASS -H "X-F5-REST-Coordination-Id: $transid" -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://[mgmt-ip]/mgmt/tm/ltm/pool/[pool-name] -d '{"name":"[pool-name]","members":[{"name":"[member-name]","state":"user-down"}]}'
commit the transactio
curl -sk -u $USERPASS -H "Accept: application/json" -H "Content-Type: application/json" -X PUT https://[mgmt-ip]/mgmt/tm/transaction/$transid -d '{ "state":"VALIDATING" }'
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects