pyControl add String
Problem this snippet solves:
This is written in python and designed to add strings to a string data group. This will need to be run in python 2.5, and need to be run by an F5 user with "write" privileges. Add strings to a file called inputfile.list, separated by line, and located in the same directory you run the below code in. Manually edit the className variable and add your data group. Currently, I've only tested it to work with "string" data groups. Integer and address have not been checked. Previously, if you tried to add a string that is already contained in the data group, it would fail out. This was mitigated with the "except"; the loop will just continue on to the next line in the inputfile.list.
Code :
#!/usr/bin/python2.5 import pycontrol.pyControl as pyControl ######################## # BIG IP CONFIG # host = '123.456.78.9' # username = 'pyControl' # password = 'pyControl' # className = 'strGroup1'# ######################## # David C. Isom # ################### # Create object b = pyControl.BIGIP( hostname = host, username = username, password = password, wsdl_files = ['LocalLB.Class'] ) c = b.LocalLB_Class f = open("inputfile.list", "r") while True: line = f.readline()[:-1] # :-1 takes out carriage return if len(line) == 0: break try: c.add_string_class_member(class_members = [{'members': [line], 'name': className}]) except: continue f.close()
Published Mar 09, 2015
Version 1.0CodeCentral_194
Cirrus
Joined May 05, 2019
CodeCentral_194
Cirrus
Joined May 05, 2019
No CommentsBe the first to comment