git://git.onelab.eu
/
nodemanager.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7acb378
)
loop on authcheck code in case session is wrong AND api is unavailable.
author
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Thu, 6 Aug 2009 20:21:20 +0000
(20:21 +0000)
committer
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Thu, 6 Aug 2009 20:21:20 +0000
(20:21 +0000)
nm.py
patch
|
blob
|
history
plcapi.py
patch
|
blob
|
history
diff --git
a/nm.py
b/nm.py
index
ed5309e
..
85c9004
100755
(executable)
--- a/
nm.py
+++ b/
nm.py
@@
-134,6
+134,7
@@
def run():
plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=iperiod/2)
#check auth
plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=iperiod/2)
#check auth
+ logger.log("Checking Auth.")
while plc.check_authentication() != True:
try:
plc.update_session()
while plc.check_authentication() != True:
try:
plc.update_session()
@@
-141,6
+142,7
@@
def run():
except:
logger.log("Retry Failed. Waiting")
time.sleep(iperiod)
except:
logger.log("Retry Failed. Waiting")
time.sleep(iperiod)
+ logger.log("Authentication Succeeded!")
while True:
while True:
diff --git
a/plcapi.py
b/plcapi.py
index
2ef5dc1
..
be77171
100644
(file)
--- a/
plcapi.py
+++ b/
plcapi.py
@@
-50,8
+50,13
@@
class PLCAPI:
def check_authentication(self):
def check_authentication(self):
- # just a simple call to check authentication
- return self.AuthCheck(self)
+ authstatus = False
+ if self.key or self.session:
+ try:
+ authstatus = self.AuthCheck()
+ except:
+ logger.log_exc()
+ return authstatus
def add_auth(self, function):
def add_auth(self, function):