Created
October 19, 2022 20:37
-
-
Save jasonrahm/ef740a79359774aabadd0a9f6f092513 to your computer and use it in GitHub Desktop.
updating system syslog parameters on BIG-IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from urllib3.exceptions import InsecureRequestWarning | |
from urllib3 import disable_warnings | |
disable_warnings(InsecureRequestWarning) | |
from bigrest.bigip import BIGIP | |
syslog_include = """ | |
filter f_remote_loghost { | |
level(warn..emerg); | |
}; | |
destination d_remote_loghost { | |
tcp("10.7.3.11" port(1468)); | |
udp("10.7.3.11" port(514)); | |
}; | |
log { | |
source(s_syslog_pipe); | |
filter(f_remote_loghost); | |
destination(d_remote_loghost); | |
}; | |
""" | |
def instantiate_bigip(host, user, password): | |
try: | |
obj = BIGIP(host, user, password, session_verify=False) | |
except Exception as e: | |
print(f"Failed to connect to {host} due to {type(e).__name__}:\n") | |
print(f"{e}") | |
sys.exit() | |
return obj | |
def update_syslog(obj, syslog_include): | |
try: | |
sl = obj.load("/mgmt/tm/sys/syslog") | |
sl.properties["include"] = syslog_include | |
obj.save(sl) | |
except Exception as e: | |
print(f"Failed to update syslog due to {type(e).__name__}:\n") | |
print(f"{e}") | |
sys.exit() | |
if __name__ == "__main__": | |
hosts = ['ltm3.test.local'] | |
user = 'admin' | |
pw = 'admin' | |
for host in hosts: | |
print(f"\nInstantiating {host}") | |
bigip = instantiate_bigip(host, user, pw) | |
print(f"\n\tUpdating {host} syslog details") | |
update_syslog(bigip, syslog_include) | |
print("\n\n---syslog update complete---\n\n") |
pip install requests and then you should be good to go. The bigrest module isn't handling dependencies properly, I'll talk to the author about that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jason,
I am getting this error when I run the script and I did the pip installs.
Traceback (most recent call last):
File "C:\py\HelloWorld\syslog_test.py", line 7, in
import bigrest.bigip
File "C:\py\HelloWorld\venv\lib\site-packages\bigrest\bigip.py", line 13, in
from .big import BIG
File "C:\py\HelloWorld\venv\lib\site-packages\bigrest\big.py", line 9, in
import requests
ModuleNotFoundError: No module named 'requests'
bigrest v1.7.3
Python 3.10.1