Forum Discussion
Create a IFile {system level} via API - Powershell
- Aug 24, 2022
Found my fault... JRahm & Patrik_Jonsson this was after my long reply to your other post JRahm (and yes it works on a POST method)... I had the file name in the URL overload specified on the initial create request, it should not be in there...
so this..$File_Name = 'MyFile' $url = "{0}{1}{2}" -f $big_ip, "/mgmt/tm/sys/file/ifile/",$File_Name $headers = @{ 'Content-Type' = 'application/json' 'X-F5-Auth-Token' = $token } $body = @{ 'name' = $File_Name 'source-path' = "file:/var/config/rest/downloads/$File_Name" } | ConvertTo-Json -Compress $result = Invoke-RestMethod -Method post -Uri $url -Headers $headers -Body $body
needs to be:$File_Name = 'MyFile' $url = "{0}{1}" -f $big_ip, "/mgmt/tm/sys/file/ifile/" $headers = @{ 'Content-Type' = 'application/json' 'X-F5-Auth-Token' = $token } $body = @{ 'name' = $File_Name 'source-path' = "file:/var/config/rest/downloads/$File_Name" } | ConvertTo-Json -Compress $result = Invoke-RestMethod -Method post -Uri $url -Headers $headers -Body $body
without the file name in the initial overload.
Hope this helps some future person 🙂
Off to the next challange.
Bonus: Retyped to splat (overload definition) - because why not.# Create a IFile {system level} $File_Name = 'MyFile' $Uri = "{0}{1}" -f $big_ip, "/mgmt/tm/sys/file/ifile/" # Construct overload definition $Param_InvokeRestMethod = @{ headers = @{ 'Content-Type' = 'application/json' 'X-F5-Auth-Token' = $token } body = @{ 'name' = $File_Name 'source-path' = "file:/var/config/rest/downloads/$File_Name" } | ConvertTo-Json -Compress Method = 'post' Uri = $Uri } # Post & capture result $result = Invoke-RestMethod @Param_InvokeRestMethod
Hi,
You can use my example with stream profile.
or modify your irule with the following code:
when HTTP_RESPONSE_DATA {
set find "<HEAD>"
set replace "<HEAD> SOME_OTHER_DATA"
if {[ regsub -all $find [HTTP::payload] $replace new_response] > 0} {
regsub -all $find [HTTP::payload] $replace newdata
log "Replacing payload with new data."
HTTP::payload replace 0 [HTTP::payload length] $newdata
HTTP::release
}
}
regards
- Fred_Slater_856Oct 21, 2015Historic F5 Account
The iApp attaches a tcp profile to the ldap virtual, with a default timeout of 300 seconds. It's a good bet that you could solve your problem by extending that. You can customize that tcp profile either by changing the iApp code or by (gulp) turning off strictness and changing the profile directly. The problem with the latter is that it will change back if you ever use the iApp again. Here's how to do things right by modifying the iApp.
- Go to the iApp templates menu and click on the f5.ldap iApp.
- Click the "Copy" button at the bottom of the window, below all of the iApp code.
- You should see "Copy_of_f5.ldap" in the Template name field. Rename it if you wish.
- Search the page (cntl-f) for the words "create ltm profile tcp". There are 4 occurrences--2 relevant to the client side and 2 relevant to the server side. The code makes it obvious which is which, even if you don't read Tcl.
- To set the timeout to 1800 seconds, on the line after each occurrence, before the right square bracket, add the words "idle-timeout 1800". The first one should look like: default-from tcp-lan-optimized idle-timeout 1800] }
- Save
- Navigate to your deployed iApp and click the Reconfigure tab.
- Next to the Template field, click "Change" and select the template that you just modified.
- Click Finished to redeploy the iApp with the new timeout values.
- elfasso_137228Oct 22, 2015
Nimbostratus
Hi Fred,
thanks for your answer. I just used the gulp-method ;) to find out if that's the idle timout that causes my problem. Result: It is.
I did not know until now, that you can easily clone an iAPP and change the parameters that suit your purposes. I have a little knowledge about TCL, but the colleague in my team that does all the scripting knows TCL very well.
You helped me a lot.
Thanks,
Thorsten
Recent Discussions
Related Content
* 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