Forum Discussion
dvalve_376192
Nov 05, 2018Nimbostratus
python show running-config
I am trying to get a Python script to output the running config of my F5, to show everything from authentication to pools to ntp settings. With TMSH/SSH it's so easy doing 'show running-config' and t...
- Nov 21, 2018
I was able to get the running config to show with Python, please see the code below:
from f5.bigip import ManagementRoot mgmt = ManagementRoot("your_f5_ip", 'username', 'password') x = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tmsh show running-config"') print(x.commandResult)
Satoshi_Toyosa1
Nov 12, 2018Ret. Employee
tmsh show running-config
is currently not supported in the iControl REST framework. You can call the /mgmt/tm/util/bash
endpoint as a workaround. A curl example is shown below:
curl -sku : https:///mgmt/tm/util/bash -X POST \
-d '{"command":"run", "utilCmdArgs":"-c \"tmsh show running-config\""}'
The output from the tmsh command is shown in the
commandResult
field. All the lines are concatenated by translating LF (0x0A) to literal \n. In bash, you may pipe the output to something like this:
| python -m json.tool | grep commandResult | sed 's/\\n/\n/g'
Of course, you can do better using Python.
See also Native tmsh/bash commands via REST API.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects