Forum Discussion
vladtache_35966
Jun 11, 2018Nimbostratus
F5 SDK | REST | map vips and ssl profiles
Hey, I would like to get the vips and the ssl profiles associated using F5 SDK. Would you please advise which will be the best method? Regards,Vlad
Give this a try for a starter:
!/usr/bin/env python3 from f5.bigip import ManagementRoot from getpass import getpass hostname = 'my.f5.ltm.net' username = 'foo' mgmt = ManagmentRoot(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), )
Give this a try for a starter:
!/usr/bin/env python3 from f5.bigip import ManagementRoot from getpass import getpass hostname = 'my.f5.ltm.net' username = 'foo' mgmt = ManagmentRoot(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), )
- vladtache_35966Nimbostratus
Thank you for your reply .
- Jason_NanceNimbostratus
Give this a try for a starter:
!/usr/bin/env python3 from f5.bigip import ManagementRoot from getpass import getpass hostname = 'my.f5.ltm.net' username = 'foo' mgmt = ManagmentRoot(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), )
- vladtache_35966Nimbostratus
Thank you for your reply .
- mevans_387580Nimbostratus
There were some syntax issue in this script
is misspelled on line 9ManagmentRoot
- Missing
on lines 13 and 17:
- Incorrect comparison operators on lines 18 and 39 (
should be=
)==
- Missing the closing
on the last line, line 67 for the print function.)
I"m not a Python guy but the script below has the modified changes that worked for me.
!/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), ))
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects