Forum Discussion

crosson_16669's avatar
crosson_16669
Icon for Nimbostratus rankNimbostratus
May 20, 2013

Sticky icontrol authentication

Consider the following script

 

 

--------------------------------

 

 

ltm_auth.py

 

import pycontrol.pycontrol as pc

 

import sys

 

 

host = sys.argv[1]

 

user = sys.argv[2]

 

passwd = sys.argv[3]

 

 

try:

 

ltm = pc.BIGIP(hostname = host, username = user, password = passwd, fromurl = True, wsdls = ['LocalLB.Pool'])

 

print "Auth Passed"

 

except Exception, e:

 

print e

 

--------------------------------

 

 

If I run the script first using correct credentials all subsoquent authentication attempts pass.

 

 

user$ python ltm_auth.py ltm.lab.com testuser CorrectPassword1

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser badpassword2

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser test

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser CorrectPassword1

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser blarg

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser billy

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser billy

 

Auth Passed

 

user$ python ltm_auth.py ltm.lab.com testuser billy

 

Auth Passed

 

 

 

If I run the script the first time with bad credentials all subsoquent connections fail.

 

user$ python ltm_auth.py ltm.lab.com testuser billy

 

HTTP Error 401: basic auth failed

 

user$ python ltm_auth.py ltm.lab.com testuser CorrectPassword1

 

HTTP Error 401: basic auth failed

 

 

What is going on here?

 

 

 

 

 

 

 

1 Reply

  • I haven't looked at the pycontrol code, but I assume it is somewhat similar to bigsuds. In the initial BIGIP object creation you are not actually creating the ZSI soap client until you call a service. If you add a arbitrary service call inside of your try/except you will get the 401 error you are looking for.

     

     

     

     import bigsuds b = bigsuds.BIGIP(hostname = '7.200.68.5', username='admin', password='this is wrong') """ This will return a BIGIP Object """ print b """This will error due to an invalid password """ try: print b.LocalLB.Pool.get_list() except bigsuds.ConnectionError: raise