Forum Discussion
Malware_Mike_37
Nov 21, 2018Altocumulus
I wasn't able to get the code from f5_rock to work (it's most likely my fault) but I did get the hostname with the code below. It's a little verbose because I had to run the tmsh command to show the settings and then I used .lstrip and .strip to clean the data up. Happy coding!
from f5.bigip import ManagementRoot
mgmt = ManagementRoot("your_f5_ip_address", 'username', 'password')
x = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tmsh list sys global-settings hostname | grep "hostname""')
hostname = str(x.commandResult)
hostname = hostname.strip().lstrip('hostname').strip()
print(hostname)