f5-admin Python API Release
Problem this snippet solves:
A complete F5 Admin API Python package. This is built for F5 security administrators. It works by providing a direct hook to the F5 TMOS Command Line Interface. Then you can manage F5 configuration objects by using your Python-Fu.
Furthermore, the security admin can go to the next level of the playing field, by custom buildout the automation procedures in the full-stack capable, object-oriented Python programming language from there. Real world examples developed to solve my daily F5 secure admin chores can be found under the 'src/bin' folder. Enjoy.
How to use this snippet:
# !/usr/bin/env python # Let's build a tool together import f5_admin # First we need to let Python know we're going to use the API f5_node = "xx-rhwebdev1" # The F5 node we want to connect to. f5_command = "show sys software" # The F5 command we want to run with f5_admin.F5Client(None,None,None) as client: client.load(f5_node) # Now we're ready to open a remote connection result=client.ssh_command(client.ssh_connect(),f5_command,"") for line in result: # line print the F5 command result in the console print(line) # Congratulation. You just build an automation tool with the API!
Test Run the Tool
Copy the above code block in a text editor. Then save it into a file name 'test.py'. Or Download it as raw file. Then you can test run the tool as below:
$ python test.py Loading cache_config: /Library/Python/2.7/site-packages/f5_admin-1.0.0-py2.7.egg/f5_admin/conf/xx-rhwebdev1/xx-rhwebdev1.txt Loading complete Setting up remote SSH session to host: xx-rhwebdev1 Please enter the F5 user name: Please enter the F5 password: Execution on the remote SSH host: show sys software Command execution complete. ---------------------------------------------------------- Sys::Software Status Volume Slot Product Version Build Active Status
Congratulation! You just build your first tool using this Python package.
Please use the url below for more usage guidelines:
https://github.com/yangsec888/f5-admin/blob/master/API.md
Tested this on version:
13.0- SamLNimbostratus
The package can now be installed directly from PyPi repository:
pip install f5-admin