git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix writing of str on os.open'ed file (needed bytes)
[nodemanager.git]
/
plcapi.py
diff --git
a/plcapi.py
b/plcapi.py
index
2ef5dc1
..
a03e9e0
100644
(file)
--- a/
plcapi.py
+++ b/
plcapi.py
@@
-1,7
+1,9
@@
-# $Id$
-
import safexmlrpc
import safexmlrpc
-import hmac, sha
+import hmac
+try:
+ from hashlib import sha1 as sha
+except ImportError:
+ import sha
import logger
class PLCAPI:
import logger
class PLCAPI:
@@
-15,7
+17,7
@@
class PLCAPI:
session => SessionAuth
To authenticate using the Boot Manager authentication method, or
session => SessionAuth
To authenticate using the Boot Manager authentication method, or
- the new session-based method.
+ the new session-based method
, respectively
.
"""
def __init__(self, uri, cacert, auth, timeout = 90, **kwds):
"""
def __init__(self, uri, cacert, auth, timeout = 90, **kwds):
@@
-26,7
+28,7
@@
class PLCAPI:
if isinstance(auth, (tuple, list)):
(self.node_id, self.key) = auth
self.session = None
if isinstance(auth, (tuple, list)):
(self.node_id, self.key) = auth
self.session = None
- elif isinstance(auth,
(str, unicode)
):
+ elif isinstance(auth,
str
):
self.node_id = self.key = None
self.session = auth
else:
self.node_id = self.key = None
self.session = auth
else:
@@
-36,7
+38,7
@@
class PLCAPI:
def update_session(self, f="/usr/boot/plnode.txt"):
def update_session(self, f="/usr/boot/plnode.txt"):
- # try authenticatipopulate /etc.planetlab/session
+ # try authenticatipopulate /etc.planetlab/session
def plnode(key):
try:
return [i[:-1].split('=') for i in open(f).readlines() if i.startswith(key)][0][1].strip('"')
def plnode(key):
try:
return [i[:-1].split('=') for i in open(f).readlines() if i.startswith(key)][0][1].strip('"')
@@
-48,10
+50,15
@@
class PLCAPI:
open("/etc/planetlab/session", 'w').write(plc.GetSession().strip())
self.session = open("/etc/planetlab/session").read().strip()
open("/etc/planetlab/session", 'w').write(plc.GetSession().strip())
self.session = open("/etc/planetlab/session").read().strip()
-
+
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("plcapi: failed in plcapi.check_authentication")
+ return authstatus
def add_auth(self, function):
def add_auth(self, function):
@@
-78,10
+85,10
@@
class PLCAPI:
# Yes, the comments in the old implementation are
# misleading. Keys of dicts are not included in the
# hash.
# Yes, the comments in the old implementation are
# misleading. Keys of dicts are not included in the
# hash.
- values += canonicalize(
arg.values(
))
+ values += canonicalize(
list(arg.values()
))
else:
# We use unicode() instead of str().
else:
# We use unicode() instead of str().
- values.append(
unicode
(arg))
+ values.append(
str
(arg))
return values
return values