andy_12_5042
Jan 03, 2011Nimbostratus
f5 connection string with pycontrol
I have written a class and defined some methods that work great so far. I am wondering however how I can get around having to pass in the connection string for wsdls on every call though??let me try to explain better:
At present if I want to operate on lots of F5's, I have to do something like below and then feed into a for loop where the ip/hostname for the F5 is a varaible that can be iterated over. I have to do this inside each function though and it is ugly. I know this must not be the best way......
b = pc.BIGIP(
hostname = 'ip',
username = 'user',
password = 'pass',
fromurl = True,
wsdls = ['LocalLB.ProfileClientSSL'])
s = b.LocalLB.ProfileClientSSL
However, it would be nicer if I could create a function for the connection to the F5 and call this in main. This way I can interate over a bunch of F5's to do different things and dont have to deal with calling the s. every time I want to do something.
I cant figure out how to acomplish this because if I make the above a function, the variable s = b.LocalLB.ProfileClientSSL is not available to any other functions in the same class as its not global scope. There must be a better way to do this ... If I am working with a DB for example I can create a connect function and do whatever I want without this headache....
I know icontrol is different and I am still learning as I go, so maybe I am missing something here.
thanks for any help.