Forum Discussion

Rudra_Mahapatra's avatar
Rudra_Mahapatra
Icon for Nimbostratus rankNimbostratus
Sep 25, 2017

How to change persist value (in F5 LB) to "None" using rest api

Using rest api I am able to change default persistence profile from None to dest_addr / source_addr. But I am not able to change it back to "None" (using rest API) from dest_addr / source_addr.

 

"persist":[{"name":"dest_addr","partition":"Common","tmDefault":"yes"}]

 

what should be the value for name when I want to change it to "None"?

 

Regards, Rudra

 

6 Replies

  • Could you show the entire request? It should be just

    "persist":"none"

    • Rudra_Mahapatra's avatar
      Rudra_Mahapatra
      Icon for Nimbostratus rankNimbostratus

      Thanks Uni for responding...

       

      I am using HPE OO rest API PUT operation. I have specified {"persist":"none"} in body of request. And I am getting following error --> {"code":404,"message":"01020036:3: The requested persist profile (none) was not found.","errorStack":[]}

       

      As mentioned earlier, it works fine when I provide {"persist":"dest_addr"} or {"persist":"source_addr"}

       

      Regards,

       

  • uni's avatar
    uni
    Icon for Altostratus rankAltostratus

    Could you show the entire request? It should be just

    "persist":"none"

    • Rudra_Mahapatra's avatar
      Rudra_Mahapatra
      Icon for Nimbostratus rankNimbostratus

      Thanks Uni for responding...

       

      I am using HPE OO rest API PUT operation. I have specified {"persist":"none"} in body of request. And I am getting following error --> {"code":404,"message":"01020036:3: The requested persist profile (none) was not found.","errorStack":[]}

       

      As mentioned earlier, it works fine when I provide {"persist":"dest_addr"} or {"persist":"source_addr"}

       

      Regards,

       

  • Use

    null
    (without quotation) or
    {}
    (means empty object). Also, use
    PATCH
    for modification. For example (using curl),

    Check the current persistence configuration of the virtual

    VS-HTTP
    (with
    dest_addr
    ).

     curl -sku user:pass https:///mgmt/tm/ltm/virtual/VS-HTTP?\$select=persist
    

    Output as below:

    { persist:
       [ { name: 'dest_addr',
           partition: 'Common',
           tmDefault: 'yes',
           nameReference: { link: 'https://localhost/mgmt/tm/ltm/persistence/dest-addr/~Common~dest_addr?ver=12.1.2' } } ] }
    

    Change it to "none".

     curl -sku user:pass https:///mgmt/tm/ltm/virtual/VS-HTTP \
      -H "Content-Type: application/json" \
      -X PATCH -d '{"persist":{}}'
    

    Now check it again using the GET request. The output should show:

    {}
    

    See also "About null values and properties" section of iControl® REST API User Guide, Version 12.1.0, p. 18.

  • I would agree the behavior on this seems to not follow some other API calls, however, the code below should work if you don't mind seeing it in PowerShell.

     

    $link = "https://${bigip}/ltm/virtual/~${partition}~${vs}" $hash = @{} $hash.Add("name", ${vs}) $hash.Add("partition", ${partition}) $hash.Add("tmDefault", "yes") $hash.Add("persist", $null)

     

    $json = $hash | ConvertTo-Json

     

    Invoke-RestMethod -Method Patch -Uri ${link} -Credential ${cred} -Body ${json} -ContentType 'application/json' -ErrorAction Stop