Skip to content

Instantly share code, notes, and snippets.

@jantman
Created January 7, 2016 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jantman/4bc3521f14a1ede7ac13 to your computer and use it in GitHub Desktop.
Save jantman/4bc3521f14a1ede7ac13 to your computer and use it in GitHub Desktop.
bigsuds_python_f5_set_pool_for_vip
# This is a COMPLETELY UNTESTED code sample, written off the top of my head. Consider it pseudocode.
# It also needs more error checking; BigSuds *should* raise exceptions for any problem.
import re
import bigsuds as pc
# INPUTS
vip_name = 'myvip'
new_pool_name = 'bluepool' # the pool to send traffic to
# connect
conn = pc.BIGIP(hostname='', username='', password='')
# make sure the device is running the major version we expect
version = conn.System.SystemInfo.get_version()
if not re.match(r'^BIG-IP_v10\.', version):
raise RuntimeError('this code is written for BigIP version 10.x, not %s' % version)
# print the current pool name
# see https://devcentral.f5.com/wiki/iControl.LocalLB__VirtualServer__get_default_pool_name.ashx
curr_pool = conn.LocalLB.VirtualServer.get_default_pool_name([vip_name])
print("%s current default pool: %s" % (vip_name, curr_pool))
# set the new default pool
print("Setting %s default pool to: %s" % (vip_name, new_pool_name))
# see https://devcentral.f5.com/wiki/iControl.LocalLB__VirtualServer__set_default_pool_name.ashx
conn.LocalLB.VirtualServer.set_default_pool_name([vip_name], [new_pool_name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment