Forum Discussion

dgadling_22282's avatar
dgadling_22282
Icon for Nimbostratus rankNimbostratus
Mar 21, 2010

pycontrol v2 auth strangeness

Short version: Is anybody having issues changing the username/password of various pycontrol objects?

 

 

Long version:

 

I'm wrapping up pycontrol2 to make life easier for myself. Our LBs have a limited-privilege account everybody can use. It's got read only access and a few simple toggles that it can do. People that need more sophisticated access to the LBs have such.

 

 

So I've got some code, Click here, that works like so:

 

 

1) make a new LB() object, it defaults to the read-only account.

 

2) call lb.save()

 

3) Exception is thrown so lb.authenticate() is called, all the f5 attributes of the lb object are updated with new suds auth info

 

4) save() tries to do its thing again, and succeeds.

 

 

However, if I do this:

 

 

1) make a new LB() object

 

2) make a new Pool() object tied to LB() from 1

 

3) Try to add_members

 

 

The following happens:

 

1) lower access user can't add members to a pool

 

2) authenticate gets called

 

3) member add tries again and fails

 

4) goto 2

 

 

While I was writing this I was logged into the web UI so I could quickly clear out my pool and test adding again. Getting frustrated at the auth not working I logged out of the web UI and walked away.

 

 

After coming back 15-20 minutes later, I decided to run my test script on a lark. It worked! Odd, I didn't think I'd changed anything, but I'll take what I can get. So I log into the web UI, clear out the pool, and hit up-arrow, enter. Now the script loops, prompting me for authentication.

 

 

So apparently being logged in to the web UI has something do with it. Any ideas?
  • Need to wait at least 20 minutes after logging out of the web UI before it works again. I basically did this:

     

    1) Log out

     

    2) Run script, fail

     

    3) Wait 5 minutes

     

    4) Run script, fail

     

    5) Wait 5 minutes

     

    6) Run script, fail

     

    7) Wait 10 minutes

     

    8) Run script, pass
  • Also of interest, if I start out with elevated privileges, this works every time w/o issue. It's something to do with changing the user/password that's flaky. It's also, so far, only flaky with the Pool object, the ConfigSync object doesn't appear to have any issues.
  • N/M, my bad apparently. The fancy meta-programming didn't work nearly as well as just calling __init__ again.
  • Thanks for the post on this. I really like that idea of catching the exception and standing up auth again. Sounds like a useful trick.

     

    -Matt