Forum Discussion

chrisb10_232790's avatar
chrisb10_232790
Icon for Nimbostratus rankNimbostratus
Dec 14, 2015

F5 Rest API: PUT method is removing pool member properties

We are attempting to use the Rest API to update multiple pool members at a time. The way we are attempting to do that is by doing a PUT to a URL similar to this:

 

PUT

 

http:///mgmt/tm/ltm/pool/a-chris-test3 { "members" : [ { "name" : "hostname:0", "session" : "user-enabled", "state" : "user-up" , { "name" : "hostname2:0", "session" : "user-disabled", "state" : "user-down" } ] }

 

Even though the API documentation states “Modifying a configuration object: The PUT method allows modifications to properties of a configuration object without affecting any other properties.“, it looks like modifying the pool members in this way actually runs a “replace-all-with” command on the backend that actually wipes the ratio and other properties in the pool members.

 

Dec 14 09:19:05 hostname notice tmsh[7389]: 01420002:5: AUDIT - pid=7389 user=wtsltmt folder=/Common module=(tmos) status=[Command OK] cmd_data=modify ltm pool a-chris-test3 { members replace-all-with { hostname:0

 

Are we running into a bug?

 

4 Replies

  • The command we would like to run is this: modify ltm pool a-chris-test3 { members modify .... Is there an API service that accomplishes this?
  • Good question, would like to know how to update state for multiple pool members across multiple pools with minimal amount of REST calls. Perhaps @jrahm has golden solution?
  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Have you tried the PATCH method instead of PUT?

     

    From the REST guide "To address different requirements, iControl REST implements both PATCH and PUT methods. In iControl REST, the PATCH method modifies only the properties that you specify in a request. The PUT method modifies the properties that you specify in a request and sets the remaining properties to either default values or empty values."

     

    My lab not available at the mo to test myself I'm afraid.

     

    N

     

  • 1) An update does not perform a "deep" or recursive update on a resource. It is similar to a dict.update() in python. i.e. it replaces each attribute: e.g. old[LoadBalancingMode] = update[LoadBalancingMode], old[members] = new[members], &c.

    This is standard for REST implementations. If you want to update the members, you need to send an update request to each member resource (

    /pool//members//
    )

    2) Notice I said "update" instead of PUT or PATCH. At least as of v11.5.4, PUT works as an update. Essentially, PUT and PATCH seem to be identical. This is bad. PUT is supposed to be "replace", not "update". That's what PATCH is for.

    That being said, even PATCH is not typically going to be recursive, although that is up to how it is implemented.