Forum Discussion
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.
- andy_12_5042NimbostratusI suppose ,as I am thinking ,I could just make calls to multiple functions within a function to accomplish a given task. For example to create a virtual server and profile. I am probably trying to overcomplicated things and not thinking in a object oriented way......
- andy_12_5042Nimbostratussorry for the flurry here but maybe someone could explain how the actual connection to the F5 works when calling wsdls and performing some action. I know it is ssl and uses authentication but wonder if anyone could give any more details..
- L4L7_53191NimbostratusAndy: to call against multiple systems, you've got a few options. Note that the actual transport is good ol' urllib2, handled by suds - nothing too fancy there. Your design concerns are valid, because it's super inefficient to call against and instantiate a BigIP object for each one of your systems. In a large environment this wouldn't scale well at all. Fortunately though, you've got some options.
- andy_12_5042Nimbostratuswow thanks for all the data!! It will take me a bit to check all this stuff out but lets see if I can get something from one of these options.... I will post back here after I have investigated all of this and tried a few things..
- andy_12_5042NimbostratusHey Matt.....
- andy_12_5042NimbostratusI did figure out a way that I could use the local directory method for the WSDLS, which is good, but I would still like to know how to do it the other way. I think I will post another thread on this .
- L4L7_53191NimbostratusThe location option is tied to the endpoint (bigip) that you call methods against, and you change it after you've parsed the wsdl. So, for example, you'd load up LocalLB.Pool (locally or via fromurl=True). Once that happens, you can change the system that you want to call against, as opposed to the transport method itself. An example of this is in the concurrentcall.py:
- andy_12_5042Nimbostratushey thanks Matt. I actually found a video tutorial that you have here, which was great and explained everything.
- L4L7_53191NimbostratusPlease dig that up if you can! I found that error on 2.6 but it was fixed at some point leading up to 2.7 - the fix that I tried, without success, was to import sys and increase the recursion limit via sys.setrecursionlimit. No luck at all.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects