Forum Discussion
mshoaib
Nov 28, 2020Altocumulus
I came across BIGREST and found it much cleaner and easier to use.
I learned the syntax and developed the solution using BIGREST instead of f5-common-pyton.
Thank you Leonardo.
Below is the code snippet that will toggle Server side SSL profile.
# Connect to BigIP
domain_name = "www.example.com-https"
b = BIGIP(ip, username, password)
# Load the Profiles on a virtual server
profiles = b.load(f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles")
print(f"List of Profiles attached to {domain_name}")
profile_context_list = []
for p in profiles:
profile_context_list.append(p.properties["context"])
print(profile_context_list)
if "serverside" in profile_context_list:
print("Serverside SSL applied")
print("Deleting Serverside SSL profile")
path = (
f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles/{rest_format(profile_name)}"
)
b.delete(path)
else:
print("Serverside SSL doesn't applied")
print("Adding Serverside SSL Profile")
data = {}
data["name"] = profile_name
data["context"] = "serverside"
b.create(f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles", data)
Complete code is here :
https://github.com/mshoaibshafi/nre-tools/tree/main/f5