Forum Discussion

Arindam_Majumde's avatar
Arindam_Majumde
Icon for Altocumulus rankAltocumulus
Jul 10, 2019

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.

7 Replies

  • 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

     

     

  • I also made sure bigipconfig.ucs file has been properly saved first and then I sent the request above.

     

  • 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"}

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    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