+ else:
+ self.node_id = self.key = self.session = None
+
+ self.server = safexmlrpc.ServerProxy(self.uri, self.cacert, self.timeout, allow_none = 1, **kwds)
+
+
+ def update_session(self, f="/usr/boot/plnode.txt"):
+ # 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('"')
+ except:
+ return None
+
+ auth = (int(plnode("NODE_ID")), plnode("NODE_KEY"))
+ plc = PLCAPI(self.uri, self.cacert, auth, self.timeout)
+ 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:
+ authstatus = self.AuthCheck()
+ except:
+ logger.log_exc("plcapi: failed in plcapi.check_authentication")
+ return authstatus