uisomdc_95191
Sep 04, 2008Nimbostratus
adding strings to data group
so we had a whole bunch of stuff to add to a string data group, but didn't feel safe giving operators privs to do this manually. in comes pycontrol and the class wsdl. This will iterate over inputfile.list, chop off carriage returns (you may need to take that part out depending on your inputfile), and submit it all to pyTest data group. I've only tried this for strings.
The try/except may not be all that elegant to prevent adding duplicate entries, but it works.
addString.py
!/usr/bin/python2.5
import pycontrol.pyControl as pyControl
BIG IP CONFIG
host = '123.456.78.9'
username = 'pyControl'
password = 'pyControl'
className = 'pyTest'
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()