with code like this I can get list of virtuals and list of their applied profiles, but all I get for a profile is name and partition…
How do I get the actual profile objects so I can inspect their details?
vips = mgmt.tm.ltm.virtuals.get_collection()
for vip in vips:
print(vip.name)
profiles = vip.profiles_s.get_collection()
for p in profiles:
print("/{}/{}: {}".format(p.partition,p.name,p))
If I want to associate what profiles from the first output are Client SSL profiles, I need to compare both outputs.
For SDK is the same.
# CAPTURE ALL CLIENT SSL PROFILES
client_ssls = session.tm.ltm.profile.client_ssls.get_collection()
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/profile/client-ssl
# CAPTURE ALL VIRTUALS
virtuals = session.tm.ltm.virtuals.get_collection()
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/virtual
# SHOW VS AND THEIR CLIENT SSL PROFILES
for virtual in virtuals:
print("------------")
print("Virtual: {}".format(virtual.name))
listClientSsl_inUse = []
for profile in virtual.profiles_s.get_collection():
# https:// <F5_mgmt_IP>/mgmt/tm/ltm/virtual/<virtual_name>/profiles
if profile.name in listClientSsl:
listClientSsl_inUse.append(profile.name)
if listClientSsl_inUse:
for prof in listClientSsl_inUse:
print("Client SSL: {}".format(prof))
else:
print("Client SSL: None")
Thanks a lot Dario. That is great! I wonder though, if there is a way to “load” the profile directly using the information provided by the profile object found in the virtual server.
In my code above, I get the profile in variable “p”, which has an attribute “attrs”, which pprinted looks like this:
Cool. I was hoping for a way to get the profile without even knowing it is an client_ssl or tcp profile… but I guess that’s what the API provides. One needs to figure out what the all possible profile types are and how to pull them all, then perform lookups based on profile name, hoping that is unique.