X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plcapi.py;h=acccda0e36d19afb3e8b024bdb34602f43808c13;hb=9e6b9c1ea9e020c55c85b433bac47231d63e9ffd;hp=a2d31cbd0cc812e095edb02bdb5529eb33b777c8;hpb=74a8cfb9d2eac39ae02e5323e1fb5b1d33297981;p=nodemanager.git diff --git a/plcapi.py b/plcapi.py index a2d31cb..acccda0 100644 --- a/plcapi.py +++ b/plcapi.py @@ -1,8 +1,9 @@ -# $Id$ -# $URL$ - import safexmlrpc -import hmac, sha +import hmac +try: + from hashlib import sha1 as sha +except ImportError: + import sha import logger class PLCAPI: @@ -16,7 +17,7 @@ class PLCAPI: 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): @@ -37,7 +38,7 @@ class PLCAPI: 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('"') @@ -49,13 +50,13 @@ class PLCAPI: open("/etc/planetlab/session", 'w').write(plc.GetSession().strip()) self.session = open("/etc/planetlab/session").read().strip() - + def check_authentication(self): authstatus = False if self.key or self.session: - try: + try: authstatus = self.AuthCheck() - except: + except: logger.log_exc("plcapi: failed in plcapi.check_authentication") return authstatus