Forum Discussion

kingikra_210056's avatar
kingikra_210056
Icon for Nimbostratus rankNimbostratus
Jul 13, 2015

Change 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 upgrade/downgrade their version separately. What it means, is that I want to be able to send a curl REST API command to two different pools of that'll enable/disable members at one go.

 

Hope that was clear enough. Please let me know if it wasn't clear enough.

 

Thanks Gil

 

8 Replies

  • That isn't possible in a single REST command, but you could execute multiple commands in order from a script (for instance look for the successful result of the first before committing the second).

     

  • Hi,

     

    That is not good enough as we'll suffer from a second or more of a downtime (it takes more then a second for the command to return). What I though is as follows: 1) Run the first command in the background (&) and wait for the second one to return. Problem is I'm not sure how it'll affect the F5 2) (Maybe a better solution if possible), use GET request to get all the members in all the pools I need to reconfigure and then use PUt to change the nodes status from disable to enable and vice versa.

     

    Thanks Gil

     

  • Another 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" }'
    
  • Hi,

     

    Bad news. I have tested the above solution on our environment. It sometimes work and sometimes not. Looks like a bug. If I add three curl requests for a change in three different pools for a certain transaction and commit this transaction, it sometimes changes the nodes on all pools, sometimes it changes only two of the three pools and sometimes even changes only one of the pools and leave the other two unchanged. We have asked F5 local support and they claim that it looks like a bug. We have opened a case and been asked to run some commands on the F5 so they'll have detailed logs.

     

    Hope it'll be solved ASAP.

     

    Thanks Gil

     

  • Some more info on this issue. I haven't mentioned that we are using Jenkins build server to deploy our site on our servers and use the F5 REST API to disable upgraded servers. When I'm writing a shell script and run it from a certain machine, so far, all is working good. When I'm running the same script (copy and paste) from a Jenkins job, it sometimes work and sometimes doesn't. We have asked F5 support and all they have suggested us to do is to use tcpdump on the F5 machine. I actually want to know what happens on the F5 transaction wise. Before committing the transaction, is there any way I can see which commands are attached to the transaction? If all the commands are attached to this transaction as should be, is there any other log that can show me what's going wrong?

     

    Thanks Gil