pyControl Creates a pool and adds VS for GTM

Problem this snippet solves:

This script creates a pool and adds a VS for GTM

Code :

####Creates a pool and more....
import pycontrol.pyControl as pyControl

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

  
d = b.GlobalLB_Pool


##Creates the Pool and this script adds two virtual servers
##This secton also specifys the LB_METHOD

try:
        
        d.create(
pool_names = ['pypool1'],
lb_methods = ['LB_METHOD_GLOBAL_AVAILABILITY'],
                           members = [[{'member': {'address': '10.10.10.100', 'port': 80}, 'order': 0},
                         {'member': {'address': '10.10.10.101', 'port': 80}, 'order': 1}]],

)
        print "Pool was created"



except:     

print "Pool Creation failed. Check log."

###############This section creates the alternate LB_Method
try:

d.set_alternate_lb_method(
pool_names = ['pypool1'],
lb_methods = ['LB_METHOD_STATIC_PERSIST']
)


        print "Alternate LB_method applied"

except: print "Alternate LB_method applied failed"


###################Creates Fallback IP

try:

d.set_fallback_ip(
pool_names = ['pypool1'],
ips  = ['192.168.1.1']
)

print "Fallback ip was applied "

except: print "Fallback ip applied failed"

#Creates Monitor associated with Pool 
try:

 d.set_monitor_association (
 
monitor_associations = [{'monitor_rule': {'monitor_templates': ['http'],
                                         'quorum': 0,
                                         'type': 'MONITOR_RULE_TYPE_SINGLE'},
                                         'pool_name': 'pypool1'}]
   
           ) 
       
 
 print "Monitor was applied to pool"
       
    
        
except:      print "Monitor failed to be applied. Check log.
Published Mar 09, 2015
Version 1.0

Was this article helpful?

No CommentsBe the first to comment