-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added autoRefresh option for regular login (non-websocket connections) #34
Conversation
Thanks for the contribution. We'll also have to address the CI issues identified circleci, travis-ci, and codacy before we can merge this PR. |
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
==========================================
+ Coverage 65.15% 67.34% +2.18%
==========================================
Files 8 8
Lines 924 1087 +163
==========================================
+ Hits 602 732 +130
- Misses 322 355 +33
Continue to review full report at Codecov.
|
@kprav33n pls review the websocket auto refresh and test code. autoRefresh param during Login() controls both autoRefresh of Login Sessions AND subscriptions - if we need different knobs for both separately, can do it too - my guess is that single knob is simple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments. Some minor style issues suggested. We can take care of some now, and others later.
pyaci/core.py
Outdated
|
||
#Web Socket Statuses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#Web Socket Statuses | |
# Web Socket Statuses |
pyaci/core.py
Outdated
|
||
#Web Socket Statuses | ||
WS_OPENING = 'Websocket Opening...' | ||
WS_OPEN = 'Websocket Open.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WS_OPEN = 'Websocket Open.' | |
WS_OPENED = 'Websocket Opened.' |
pyaci/core.py
Outdated
|
||
#Web Socket Statuses | ||
WS_OPENING = 'Websocket Opening...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WS_OPENING = 'Websocket Opening...' | |
WS_OPENING = 'Websocket Opening.' |
pyaci/core.py
Outdated
self._autoRefresh = False | ||
self._autoRefreshThread = None | ||
self._login = {} | ||
self._autotest = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled to have test specific handling in the product code. We'll leave this for now, and discuss later how to remove it.
if 'APIC-cookie' in self._rootApi()._session.cookies : | ||
token = self._rootApi()._session.cookies['APIC-cookie'] | ||
else: | ||
raise Exception('APIC-cookie NOT found.. Make sure you have logged in.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have specific exceptions/errors thrown instead of the blanket Exception. We can handle this later.
pyaci/core.py
Outdated
@@ -698,12 +731,102 @@ def _spawnChildFromAttributes(self, className, **attributes): | |||
return self._spawnChildFromRn(className, rn) | |||
|
|||
|
|||
class autoRefreshThread(threading.Thread): | |||
def __init__(self, rootApi): | |||
super(autoRefreshThread, self).__init__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(autoRefreshThread, self).__init__() | |
super(AutoRefreshThread, self).__init__() |
pyaci/core.py
Outdated
|
||
def run(self): | ||
logger.debug('arThread: Starting up...') | ||
REFRESH_BEFORE = 60 #approx - this many seconds before expiry, do refresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REFRESH_BEFORE = 60 #approx - this many seconds before expiry, do refresh | |
REFRESH_BEFORE = 60 # approx - this many seconds before expiry, do refresh |
pyaci/core.py
Outdated
def run(self): | ||
logger.debug('arThread: Starting up...') | ||
REFRESH_BEFORE = 60 #approx - this many seconds before expiry, do refresh | ||
CHECK_INTERVAL = 10 #how long to sleep before waking to check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHECK_INTERVAL = 10 #how long to sleep before waking to check | |
CHECK_INTERVAL = 10 # how long to sleep before waking to check |
pyaci/core.py
Outdated
logger.debug('arThread: Starting up...') | ||
REFRESH_BEFORE = 60 #approx - this many seconds before expiry, do refresh | ||
CHECK_INTERVAL = 10 #how long to sleep before waking to check | ||
WS_REFRESH_INT = 40 #approx - this many seconds before subscription refresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WS_REFRESH_INT = 40 #approx - this many seconds before subscription refresh | |
WS_REFRESH_INT = 40 # approx - this many seconds before subscription refresh |
pyaci/core.py
Outdated
int(doc['imdata']['aaaLogin']['@refreshTimeoutSeconds']) | ||
logger.debug(root._login) | ||
if root._autoRefresh: | ||
arThread = autoRefreshThread(root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arThread = autoRefreshThread(root) | |
arThread = AutoRefreshThread(root) |
@kprav33n addressed code review comments - removed the knob for testing in the production code by restructuring the code. only thing to discuss and do later is: exceptions from pyaci |
Thank you for meticulously taking care of all review comments. Appreciate the contribution. Merged. |
This should resolve #16