Tinkering with the BIGREST Python SDK - Part 1
A couple months back, Leonardo Souza (one of our MVPs) released a new SDK for interacting with the iControl REST interface. A write up right here on DevCentral covers the high level basics of why he ...
Published Sep 01, 2020
Version 1.0JRahm
Admin
Joined January 20, 2005
JRahm
Admin
Joined January 20, 2005
mshoaib
Nov 28, 2020Cirrus
Great article and awesome new SDK that i found out right on time.
I was struggling with "f5-common-python" to add/remove server side ssl to a virtual server.
I found BIGREST cleaner syntax and easy to understand.
Below is the snippet i used to do what I was looking for:
domain_name = input()
# Connect to BigIP
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 : https://github.com/mshoaibshafi/nre-tools/tree/main/f5
Thank you,
Muhammad