# so that it is immediately visible at myplc (gui or api).
#
+from __future__ import print_function
+
import xml, xmlrpclib
import logging
import time
import sys
import os
import string
+import ssl
CONFIG_FILE = "/tmp/source/configuration"
SESSION_FILE = "/etc/planetlab/session"
parts = string.split(line, "=")
if len(parts) != 2:
- print "Invalid line in vars file: {}".format(line)
+ print("Invalid line in vars file: {}".format(line))
validConfFile = False
break
vars_file.close()
if not validConfFile:
- print "Unable to read configuration vars."
+ print("Unable to read configuration vars.")
return vars
def __init__(self, auth, url):
self.auth = auth
self.url = url
- self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
+ # Using a self signed certificate
+ # https://www.python.org/dev/peps/pep-0476/
+ if hasattr(ssl, '_create_unverified_context'):
+ self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True,
+ context=ssl._create_unverified_context())
+ else :
+ self.api = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
def __getattr__(self, name):
method = getattr(self.api, name)
f.write("{}\n".format(pid))
f.close()
except:
- print "Uuuhhh.... this should not occur."
+ print("Uuuhhh.... this should not occur.")
sys.exit(1)
def start_and_run():
api.AuthCheck()
break
except:
- print "Retry in 30 seconds: ", os.popen("uptime").read().strip()
- traceback.print_exc()
+ print("Retry in 30 seconds: ", os.popen("uptime").read().strip())
+ traceback.print_exc(limit=5)
time.sleep(30)
try:
api.ReportRunlevel({'run_level' : 'failboot'})
except:
- print "reporting error: ", os.popen("uptime").read().strip()
+ print("reporting error: ", os.popen("uptime").read().strip())
traceback.print_exc()
sys.stdout.flush()