pyControl Create Wide-IP on GTM

Problem this snippet solves:

This script is for adding Wide_IPs

Code :

import pycontrol.pyControl as pyControl

#Create the BigIP object

b = pyControl.BIGIP(hostname   = '10.10.10.10',
    username   = 'admin',
    password   = 'admin',
    wsdl_files = ['GlobalLB.WideIP']
    )

#Creat the WideIP,LB_Method and add pools. here we are setting the ratios for the pools    
d = b.GlobalLB_WideIP

try:
d.create(
              wide_ips = ['www.pycontrol.com'],
    lb_methods = ['LB_METHOD_GLOBAL_AVAILABILITY'],
  wideip_pools = [[{'order': 1, 'pool_name': 'pypool1', 'ratio': 1}]],
  wideip_rules = []

)


print "WideIP was Created."




except:print "WideIPcreate error. Check log."


#### This is the section where we are adding an alias to the WideIP.

try:
d.add_alias(
              wide_ips = ['www.pycontrol.com'],
      aliases  = [['ww2.pycontrol.com',
                           'ww3.pycontrol.com',   
                          'ww4.pycontrol.com',
                           'www.foo.com']]
      

)


print "WideIP-Alias was Created."




except:print "WideIP aslias create error. Check log.
Published Mar 09, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment