pyControl adding BIG-IP to DC for GTM
Problem this snippet solves:
This script adds a bigip to a DC on GTM. This script can be used for any server type by modifing the srever_type and the monitor type.
Code :
#This scripted is for adding a BIGIP to a datacenter. You can utilize #it to add any type of server to a datacenter. This scrip is pass #fail. #there is no explicite errorchecking. # import pycontrol.pyControl as pyControl #import sys #import sys, traceback #Create the BigIP object b = pyControl.BIGIP(hostname = '10.10.10.10', username = 'admin', password = 'admin', wsdl_files = ['GlobalLB.Server'] ) # d = b.GlobalLB_Server #this secontion addes a bigip or server to a datacenter # if you want to add another type of server all you have to do is # change the types=value try: d.create( servers = [{'addresses': [{'addresses_on_unit': ['172.16.2.10'], 'unit_id': 1}], 'server': 'test_bigip12'}], types = ['SERVER_TYPE_BIGIP_STANDALONE'], data_centers = ['pyControl-DC'] ) print "Server was created and added to a datacenter" except: print "Server Creation failed. Check log." #Since this is a bigIP we are going to associate the BigIP health monitor try: d.set_monitor_association ( monitor_associations = [{'monitor_rule': {'monitor_templates': ['bigip'], 'quorum': 0, 'type': 'MONITOR_RULE_TYPE_SINGLE'}, 'server_name': 'test_bigip12'}] ) print "Monitor was applied to server" except: print "Monitor failed to be applied. Check log."
Published Mar 09, 2015
Version 1.0