[Debian] 改版
1測試
#!/usr/bin/env python3
from f5.bigip import ManagementRoot
import sys
from ciscoconfparse import CiscoConfParse
#https://devcentral.f5.com/s/question/0D51T00006i7jW8SAI/python-show-runningconfig
#https://f5-sdk.readthedocs.io/en/latest/ F5 SDK documentation
#https://pypi.org/project/ciscoconfparse/ ciscoconfparse documentation
mgmt = ManagementRoot('IP', 'USERNAME', 'PASSWORD')
x = mgmt.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tmsh running-config"')
output = x.commandResult
with open('output.conf', 'w') as f:
print(output, file=f)
parse = CiscoConfParse('pathtofile/output.conf', syntax='junos', comment='#')
for intf_obj in parse.find_objects('auth ldap system-auth'):
samaccount = intf_obj.re_match_iter_typed('\s+login-attribute\s(.*)', default="")
print(samaccount)
if samaccount == 'samaccountname':
print("Woohoo")
沒有留言:
張貼留言