03-Feb-2023 01:18
Hi guys,
Is there any way that I can retrieve output of this command "imish -e "show ip bgp neighbors" via API? Or if not, do you know how I can parse the output of this command from netmiko to something (for example: dictionary) that can be processed further? Thanks
03-Feb-2023
02:40
- last edited on
05-Jun-2023
10:53
by
JimmyPackets
You can run linux commands with REST-API as needed this a month go and you are using the API endpoint
mgmt/tm/util/bash
and utilCmdArgs .
Check:
https://community.f5.com/t5/technical-forum/running-bash-commands-via-rest-api/td-p/272516
https://community.f5.com/t5/technical-forum/native-tmsh-bash-commands-via-rest-api/td-p/118662
03-Feb-2023 04:21
Is it possible for a imish call, not tmsh call?
03-Feb-2023 04:47 - edited 03-Feb-2023 04:49
If it is in Linux (using imish but not entering it, like in linux when you run tmsh list /sys .. for example ) I don't see why not and testing will give you answer you seek.
06-Feb-2023 02:55 - edited 06-Feb-2023 02:57
Thanks a lot. I tried with Postman but it returned 400 error with message ""\"bash\" unexpected argument",". Is there anything I can do to pass this error?
03-Feb-2023 09:31 - edited 03-Feb-2023 09:32
Other than that you can use the Ansible module "bigip_command" to do something like:
- name: BGP show
bigip_command:
commands: run util bash -c " xxxxx"
provider "{{ provider }}"
delegate_to: localhost
If you see issues add the commands in a bash script on the F5 and then trigger the script.
Not having right a F5 with a licensed routing module, so I am interested in your tests and if it worked 😀
06-Feb-2023 08:37 - edited 06-Feb-2023 08:46
Here is a working example:
curl -sku admin:xxxx https://xxxx/mgmt/tm/util/bash -X POST -H "Content-Type: application/json" -d "{\"command\":\"run\", \"utilCmdArgs\":\"-c 'ls -alt /var/log'\"}"
but better trigger a bash script file
curl -sku admin:xxxx https://xxxx/mgmt/tm/util/bash -X POST -H "Content-Type: application/json" -d "{\"command\":\"run\", \"utilCmdArgs\":\"-c 'bash /shared/niki.sh'\"}"
Also as I mentioned Ansible can be added with its commands module :