Skip to content

Instantly share code, notes, and snippets.

@mevansgh1
Created April 3, 2019 18:44
Show Gist options
  • Save mevansgh1/f652eaa810046dcbf657975de3973a44 to your computer and use it in GitHub Desktop.
Save mevansgh1/f652eaa810046dcbf657975de3973a44 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from f5.bigip import ManagementRoot
from getpass import getpass
hostname = 'my.f5.ltm.net'
username = 'foo'
mgmt = ManagementRoot(hostname, username, getpass())
print('Virtual,Client SSLs,Server SSLs')
for virtual in mgmt.tm.ltm.virtuals.get_collection():
clientssl = []
serverssl = []
for profile in virtual.profiles_s.get_collection():
if profile.context == 'clientside':
# Check to see if it is a client SSL profile
try:
# Support subPath
if hasattr(profile, 'subPath'):
pobj = mgmt.tm.ltm.profile.client_ssls.client_ssl.load(
partition=profile.partition,
subPath=profile.subPath,
name=profile.name,
)
else:
pobj = mgmt.tm.ltm.profile.client_ssls.client_ssl.load(
partition=profile.partition,
name=profile.name,
)
except:
# Not a client SSL profile (could be client TCP or other)
continue
# If we get here it is a client SSL profile
clientssl.append(pobj.fullPath)
elif profile.context == 'serverside':
# Check to see if it is a server SSL profile
try:
# Support subPath
if hasattr(profile, 'subPath'):
pobj = mgmt.tm.ltm.profile.server_ssls.server_ssl.load(
partition=profile.partition,
subPath=profile.subPath,
name=profile.name,
)
else:
pobj = mgmt.tm.ltm.profile.server_ssls.server_ssl.load(
partition=profile.partition,
name=profile.name,
)
except:
# Not a server SSL profile (could be server TCP or other)
continue
# If we get here it is a server SSL profile
serverssl.append(pobj.fullPath)
# Print virtual if it has client or server ssl profiles
if len(clientssl) > 0 or len(serverssl) > 0:
print('{},{},{}'.format(
virtual.fullPath,
';'.join(clientssl),
';'.join(serverssl),
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment