Forum Discussion

AJ_01_135899's avatar
AJ_01_135899
Icon for Cirrostratus rankCirrostratus
Jan 25, 2017

REST API Best Way to Replace HTTP Profile

Some background:

We're looking at replacing the default http profile on several hundred VIPs with a custom http profile containing different settings. To accomplish this (and to lay a foundation for future automation), we're experimenting with using the REST API. This is on LTM 12.1.1

What we can't quite figure out is the best mechanism to delete then add an http profile to a VIP using the REST API. We've tried something similar to the following (this is in PowerShell):

$LTMVIPURI = "https://myltm/mgmt/tm/ltm/virtual/~mypartition~$myvip/?ver=12.1.1&expandSubcollections=true"
$headers = @{"X-F5-Auth-Token" = $authToken}
$changedprofileJSON = '{"profiles":[{"name":"new_http_profile"}]}'

Invoke-RestMethod -Method Patch -URI $LTMVIPURI -Headers $headers -Body $changedprofileJSON -ContentType "application/json"

This appears to be successful, however it overwrites one of the other profiles listed (a stream profile). The TCP profile appears to be unaffected.

Has anyone attempted a profile change like this and if so, how did you approach it? Am I looking at doing a GET, expanding the profilesreference, making the change I need, then doing a PATCH with the entire payload of desired profiles?

Here's the profiles output before and after the PATCH command:

BEFORE

kind       : tm:ltm:virtual:profiles:profilesstate
name       : http
partition  : Common
fullPath   : /Common/http
generation : 2204
selfLink   : https://localhost/mgmt/tm/ltm/virtual/~mypartition~myvip/profiles/~Common~http?ver=12.1.1
context    : all

kind       : tm:ltm:virtual:profiles:profilesstate
name       : stream
partition  : Common
fullPath   : /Common/stream
generation : 2204
selfLink   : https://localhost/mgmt/tm/ltm/virtual/~mypartition~myvip/profiles/~Common~stream?ver=12.1.1
context    : all

kind       : tm:ltm:virtual:profiles:profilesstate
name       : tcp
partition  : Common
fullPath   : /Common/tcp
generation : 2204
selfLink   : https://localhost/mgmt/tm/ltm/virtual/~mypartition~myvip/profiles/~Common~tcp?ver=12.1.1
context    : all

AFTER

kind       : tm:ltm:virtual:profiles:profilesstate
name       : new_http_profile
partition  : Common
fullPath   : /Common/new_http_profile
generation : 2204
selfLink   : https://localhost/mgmt/tm/ltm/virtual/~mypartition~myvip/profiles/~Common~new_http_profile?ver=12.1.1
context    : all

kind       : tm:ltm:virtual:profiles:profilesstate
name       : tcp
partition  : Common
fullPath   : /Common/tcp
generation : 2204
selfLink   : https://localhost/mgmt/tm/ltm/virtual/~mypartition~myvip/profiles/~Common~tcp?ver=12.1.1
context    : all
No RepliesBe the first to reply