python f5-vserver-tool
Problem this snippet solves: What the tool does: List all virtual server, nodes and pools and their assignment for a big-ip system or device group print sync status of a device group assign a pool for a specific virtual server How to use this snippet: Usage https://github.com/FalcoSuessgott/f5-vserver-tool Print out information List virtual server and their assigned pools and their respective nodes [user@host ~]$ loadbalancer -l Password: Virtual Server Pool Pool member xxx-8010 xxxx 1.1.1.1:100, 1.1.1.1:200 xxx-8020 xxxx 1.1.1.1:100, 1.1.1.1:200 ....` List all virtual server [user@host ~]$ loadbalancer --list-vserver Password: vserver-1 vserver-2 vserver-3 ....` List all pools [user@host ~]$ loadbalancer --list-pools Password: pool-1 pool-2 pool-3 .... List all nodes [user@host ~]$ loadbalancer --list-nodes Password: node1 node2 node3 .... List all virtual server [user@host ~]$ loadbalancer --list-vserver Password: vserver-1 vserver-2 vserver-3 .... Print out sync-status [user@host ~]$ loadbalancer --show-sync-status Password: deviceGroup is currently In Sync Set assign pool1 to vserver1 [user@host ~]$ loadbalancer -s vserver1 pool1 Password: Changing pool for "vserver1" to "pool1" Synchronizing new configuration to device group "devicegroup" devicegroup is In Sync Print out sample config file [user@host ~]$ loadbalancer -m [AUTH] user = "user" password = "password" [BASIC] devicegroup = "devicegroup" loadbalancer = "fqdn" Code : https://github.com/FalcoSuessgott/f5-vserver-tool429Views0likes0CommentsDisplaying VS config using SDK
Problem this snippet solves: I have made a script in python using the SDK of F5 to display a brief information of the configuration of each existing VS. You can use this code as proof of concept of how to use F5 SDK. How to use this snippet: You need to replace this next line with the corresponding information before executing the script. session = ManagementRoot("F5_mgmt_IP","username","password",token=True) Code : import re from f5.bigip import ManagementRoot # ---------------------------------------------------------- session = ManagementRoot("F5_mgmt_IP","username","password",token=True) # CAPTURE LIST OF CLIENT SSL PROFILES client_ssls = session.tm.ltm.profile.client_ssls.get_collection() # https:// /mgmt/tm/ltm/profile/client-ssl listClientSsl = [] for client_ssl in client_ssls: listClientSsl.append(client_ssl.name) # CAPTURE LIST OF SERVER SSL PROFILES server_ssls = session.tm.ltm.profile.server_ssls.get_collection() # https:// /mgmt/tm/ltm/profile/server-ssl listServerSsl = [] for server_ssl in server_ssls: listServerSsl.append(server_ssl.name) # CAPTURE VIRTUAL SERVER INFORMATION virtuals = session.tm.ltm.virtuals.get_collection() # https:// /mgmt/tm/ltm/virtual for virtual in virtuals: print("------------") print("Partition: {}".format(virtual.partition)) if hasattr(virtual, 'subPath'): print("SubPath: {}".format(virtual.subPath)) else: print("SubPath: None") print("Virtual: {}".format(virtual.name)) if hasattr(virtual, 'description'): print("Description: {}".format(virtual.description)) else: print("Description: None") print("Destination: {}".format(re.search('[^\/]+$', virtual.destination).group(0))) listClientSsl_inUse = [] listServerSsl_inUse = [] for profile in virtual.profiles_s.get_collection(): # https:// /mgmt/tm/ltm/virtual/ /profiles if profile.name in listClientSsl: listClientSsl_inUse.append(profile.name) if profile.name in listServerSsl: listServerSsl_inUse.append(profile.name) if listClientSsl_inUse: for prof in listClientSsl_inUse: print("Client SSL: {}".format(prof)) else: print("Client SSL: None") if listServerSsl_inUse: for prof in listServerSsl_inUse: print("Server SSL: {}".format(prof)) else: print("Server SSL: None") if hasattr(virtual, 'rules'): for rule in virtual.rules: print("Rule: {}".format(re.search('[^\/]+$', rule).group(0))) else: print("Rule: None") if hasattr(virtual, 'persist'): for persist in virtual.persist: print("Persistence: {}".format(persist['name'])) else: print("Persistence: None") if hasattr(virtual, 'pool'): print("Pool: {}".format(re.search('[^\/]+$', virtual.pool).group(0))) if hasattr(virtual, 'subPath'): poolName = virtual.pool.split("/")[3] poolSubpath = virtual.pool.split("/")[2] poolPartition = virtual.pool.split("/")[1] pool = session.tm.ltm.pools.pool.load(name=poolName, subPath=poolSubpath, partition=poolPartition) # https:// /mgmt/tm/ltm/pool/ else: poolName = virtual.pool.split("/")[2] poolPartition = virtual.pool.split("/")[1] pool = session.tm.ltm.pools.pool.load(name=poolName, partition=poolPartition) # https:// /mgmt/tm/ltm/pool/ poolMembers = pool.members_s.get_collection() # https:// /mgmt/tm/ltm/pool/ /members if poolMembers: for member in poolMembers: print("Member: {}".format(member.name)) else: print("Member: None") else: print("Pool: None") print("Member: None") print("------------") # ---------------------------------------------------------- Tested this on version: 12.11.1KViews2likes4Comments