Forum Discussion
how to fetch entire big ip configuration file
does anyone know how can I fetch (not save on device) entire configuration from big ip using REST and make it viewable to the end user? Save is not an option as in this scenario the users do not have access to the real device. Please let me know.
- JG
Cumulonimbus
You can certainly create a UCS file, download it and put it where your user can access it - all with the REST API. See:
https://support.f5.com/csp/article/K13225405
https://f5-sdk.readthedocs.io/en/latest/userguide/file_transfers.html
.
- Arindam_Majumde
Altocumulus
I tried to read 512 bytes but getting error back from bigip. Any idea what is wrong? also how do I completely read the file, like knowing filesize etc.
Request
GET https://172.18.20.98/mgmt/shared/file-transfer/ucs-downloads/bigipconfig.ucs HTTP/1.1
Content-Type: application/octet-stream
X-F5-Auth-Token: VOVJQUWKAPZ3AO4KGIY4BJDNJ2
Content-Range: 512
Host: 172.18.20.98
Response
HTTP/1.1 400 Bad Request
Date: 12 Jul 2019 07:53:37 UTC
Server: com.f5.rest.common.RestRequestSender
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=16070400; includeSubDomains
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate
Expires: -1
Content-Length: 0
Content-Type: application/octet-stream
Content-Range: 512
Local-Ip-From-Httpd: 172.18.20.98
X-Forwarded-Server: localhost.localdomain
X-Forwarded-Proto: http
X-Forwarded-Host: 172.18.20.98
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' http://127.4.1.1 http://127.4.2.1
Connection: close
- Arindam_Majumde
Altocumulus
I also made sure bigipconfig.ucs file has been properly saved first and then I sent the request above.
- Arindam_Majumde
Altocumulus
I tried changing content type to application/json and added content range header but it returns "string index out of range". Here is the request/response pair (below)
Request
GET https://172.18.20.98/mgmt/shared/file-transfer/ucs-downloads/bigipconfig.ucs HTTP/1.1
Content-Type: application/json
X-F5-Auth-Token: BS3ZK3KEYLVEXBH2VD4R4RAUGD
Content-Range: 512
Host: 172.18.20.98
Response
HTTP/1.1 400 Bad Request
Date: 12 Jul 2019 16:32:16 UTC
Server: com.f5.rest.common.RestRequestSender
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=16070400; includeSubDomains
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate
Expires: -1
Content-Length: 132
Content-Type: application/json
Content-Range: 512
Local-Ip-From-Httpd: 172.18.20.98
X-Forwarded-Server: localhost.localdomain
X-Forwarded-Proto: http
X-Forwarded-Host: 172.18.20.98
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' http://127.4.1.1 http://127.4.2.1
Connection: close
{"code":400,"message":"String index out of range: -1","referer":"172.18.20.97","restOperationId":136890,"kind":":resterrorresponse"}
- Satoshi_Toyosa1Ret. Employee
May be you did not specify the Content-Range value properly: It should be
Content-Range: start-end/totalSize
e.g.,
Content-Range: 0-511/512 (for a 512 bytes file)
See also Demystifying iControl REST Part 5: Transferring Files.
- JG
Cumulonimbus
Here's a Python script that worked for me, although it took a long time to download the file:
#!/usr/bin/python3 from f5.bigip import ManagementRoot import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) API_ROOT = ManagementRoot("xx.xx.xx.xx", "admin", "admin") API_ROOT.shared.file_transfer.ucs_downloads.download_file('config.ucs', '/tmp/on_mypc_config.ucs')
This also works:
curl -sk -u admin:admin -H 'Content-Type: application/json' -X POST -d '{"command": "run", "utilCmdArgs": "-c \"tmsh show running-config all-properties\""}' https://<ip_of_bigip>/mgmt/tm/util/bash
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