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()
This is great! Would you mind my contributing it to the iControl CodeShare? Since you posted it here, I’m sure you wouldn’t but I figured I’d ask anyway…
BTW, if anyone would like alternate versions of this code (C, PowerShell, Perl, etc), let me know and I’ll whip it up for you.
Wish I could help you out but I no almost nothing about Python. I’d be able to get you going with Perl if that helps B-). Any Python folks out there care to help?
So, you’ll be needing to pass in an array of AddressClass structures each contiaining a name for the class along with an array of AddressEntry structures containing the address information.