def XMLRPC_Send(self): "Sends the report to a given XML-RPC host. Returns 0 on success or 2 on submission failure." if not self.config.xmlrpc: return 2 url = "http://%s/rteval/API1/" % self.config.xmlrpc attempt = 0 exitcode = 2 # Presume failure warning_sent = False while attempt < 6: try: client = rtevalclient.rtevalclient(url) print "Submitting report to %s" % url rterid = client.SendReport(self.xmlreport.GetXMLdocument()) print "Report registered with submission id %i" % rterid attempt = 10 exitcode = 0 # Success except socket.error: if (self.mailer is not None) and (not warning_sent): self.mailer.SendMessage("[RTEVAL:WARNING] Failed to submit report to XML-RPC server", "Server %s did not respond. Not giving up yet." % self.config.xmlrpc) warning_sent = True attempt += 1 if attempt > 5: break # To avoid sleeping before we abort print "Failed sending report. Doing another attempt(%i) " % attempt time.sleep(attempt*5*60) # Incremental sleep - sleep attempts*5 minutes except Exception, err: raise err
def XMLRPC_Send(self): "Sends the report to a given XML-RPC host. Returns 0 on success or 2 on submission failure." if not self.config.xmlrpc: return 2 url = "http://%s/rteval/API1/" % self.config.xmlrpc attempt = 0 exitcode = 2 # Presume failure warning_sent = False while attempt < 6: try: client = rtevalclient.rtevalclient(url) print "Submitting report to %s" % url rterid = client.SendReport(self.xmlreport.GetXMLdocument()) print "Report registered with submission id %i" % rterid attempt = 10 exitcode = 0 # Success except socket.error: if (self.mailer is not None) and (not warning_sent): self.mailer.SendMessage( "[RTEVAL:WARNING] Failed to submit report to XML-RPC server", "Server %s did not respond. Not giving up yet." % self.config.xmlrpc) warning_sent = True attempt += 1 if attempt > 5: break # To avoid sleeping before we abort print "Failed sending report. Doing another attempt(%i) " % attempt time.sleep(attempt * 5 * 60) # Incremental sleep - sleep attempts*5 minutes except Exception, err: raise err
def __init__(self, cmdargs): self.version = "1.37" self.load_modules = [] self.workdir = os.getcwd() self.reportdir = os.getcwd() self.inifile = None self.cmd_options = {} self.start = datetime.now() self.init = 'unknown' default_config = { 'rteval': { 'verbose': False, 'keepdata': True, 'debugging': False, 'duration': '60', 'sysreport': False, 'reportdir': None, 'reportfile': None, 'installdir': '/usr/share/rteval', 'srcdir': '/usr/share/rteval/loadsource', 'xmlrpc': None, 'xslt_report': '/usr/share/rteval/rteval_text.xsl', 'report_interval': '600', 'logging': False, }, 'loads': { 'kcompile': 'module', 'hackbench': 'module', }, 'kcompile': { 'source': 'linux-2.6.39.tar.bz2', 'jobspercore': '2', }, 'hackbench': { 'source': 'hackbench.tar.bz2', 'jobspercore': '5', }, 'cyclictest': { 'interval': '100', 'buckets': '2000', } } # setup initial configuration self.config = rtevalConfig.rtevalConfig(default_config, logfunc=self.info) # parse command line options self.parse_options(cmdargs) # read in config file info self.inifile = self.config.Load(self.cmd_options.inifile) # copy the command line options into the rteval config section # (cmd line overrides config file values) self.config.AppendConfig('rteval', self.cmd_options) if self.cmd_options.cyclictest_interval != None: self.config.AppendConfig( 'cyclictest', {"interval": self.cmd_options.cyclictest_interval}) if self.cmd_options.cyclictest_distance != None: self.config.AppendConfig( 'cyclictest', {"distance": self.cmd_options.cyclictest_distance}) if self.cmd_options.cyclictest_buckets != None: self.config.AppendConfig( 'cyclictest', {"buckets": self.cmd_options.cyclictest_distance}) if self.cmd_options.cyclictest_priority != None: self.config.AppendConfig( 'cyclictest', {"priority": self.cmd_options.cyclictest_priority}) if self.cmd_options.hackbench_jobspercore != None: self.config.AppendConfig( 'hackbench', {"jobspercore": self.cmd_options.hackbench_jobspercore}) if self.cmd_options.kcompile_jobspercore != None: self.config.AppendConfig( 'kcompile', {"jobspercore": self.cmd_options.kcompile_jobspercore}) self.debug("workdir: %s" % self.workdir) # prepare a mailer, if that's configured if self.config.HasSection('smtp'): self.mailer = rtevalMailer.rtevalMailer( self.config.GetSection('smtp')) else: self.mailer = None self.loads = [] self.cputopology = None self.numcores = None self.memsize = None self.current_clocksource = None self.available_clocksource = None self.services = None self.kthreads = None self.xml = None self.baseos = "unknown" self.annotate = self.cmd_options.annotate if not self.config.xslt_report.startswith(self.config.installdir): self.config.xslt_report = os.path.join(self.config.installdir, "rteval_text.xsl") if not os.path.exists(self.config.xslt_report): raise RuntimeError, "can't find XSL template (%s)!" % self.config.xslt_report # Add rteval directory into module search path sys.path.insert(0, '%s/rteval' % sysconfig.get_python_lib()) # generate a set of "junk" characters to use for filtering later self.junk = "" for c in range(0, 0xff): s = chr(c) if s not in string.printable: self.junk += s self.transtable = string.maketrans("", "") # If --xmlrpc-submit is given, check that we can access the server res = None if self.config.xmlrpc: self.debug("Checking if XML-RPC server '%s' is reachable" % self.config.xmlrpc) attempt = 0 warning_sent = False ping_failed = False while attempt < 6: try: client = rtevalclient.rtevalclient( "http://%s/rteval/API1/" % self.config.xmlrpc) res = client.Hello() attempt = 10 ping_failed = False except xmlrpclib.ProtocolError: # Server do not support Hello(), but is reachable self.info( "Got XML-RPC connection with %s but it did not support Hello()" % self.config.xmlrpc) res = None except socket.error, err: self.info( "Could not establish XML-RPC contact with %s\n%s" % (self.config.xmlrpc, str(err))) if (self.mailer is not None) and (not warning_sent): self.mailer.SendMessage( "[RTEVAL:WARNING] Failed to ping XML-RPC server", "Server %s did not respond. Not giving up yet." % self.config.xmlrpc) warning_sent = True # Do attempts handling attempt += 1 if attempt > 5: break # To avoid sleeping before we abort print "Failed pinging XML-RPC server. Doing another attempt(%i) " % attempt time.sleep( attempt * 15) # Incremental sleep - sleep attempts*15 seconds ping_failed = True if ping_failed: if not self.cmd_options.xmlrpc_noabort: print "ERROR: Could not reach XML-RPC server '%s'. Aborting." % self.config.xmlrpc sys.exit(2) else: print "WARNING: Could not ping the XML-RPC server. Will continue anyway." if res: self.info( "Verified XML-RPC connection with %s (XML-RPC API version: %i)" % (res["server"], res["APIversion"])) self.debug("Recieved greeting: %s" % res["greeting"])
def __init__(self, cmdargs): self.version = "1.41" self.load_modules = [] self.workdir = os.getcwd() self.reportdir = os.getcwd() self.inifile = None self.cmd_options = {} self.start = datetime.now() self.init = 'unknown' default_config = { 'rteval': { 'verbose' : False, 'keepdata' : True, 'debugging' : False, 'duration' : '60', 'sysreport' : False, 'reportdir' : None, 'reportfile' : None, 'installdir' : '/usr/share/rteval', 'srcdir' : '/usr/share/rteval/loadsource', 'xmlrpc' : None, 'xslt_report': '/usr/share/rteval/rteval_text.xsl', 'report_interval': '600', 'logging' : False, }, 'loads' : { 'kcompile' : 'module', 'hackbench' : 'module', }, 'kcompile' : { 'source' : 'linux-2.6.39.tar.bz2', 'jobspercore': '2', }, 'hackbench' : { 'source' : 'hackbench.tar.bz2', 'jobspercore': '5', }, 'cyclictest' : { 'interval' : '100', 'buckets' : '2000', } } # setup initial configuration self.config = rtevalConfig.rtevalConfig(default_config, logfunc=self.info) # parse command line options self.parse_options(cmdargs) # read in config file info self.inifile = self.config.Load(self.cmd_options.inifile) # copy the command line options into the rteval config section # (cmd line overrides config file values) self.config.AppendConfig('rteval', self.cmd_options) if self.cmd_options.cyclictest_interval != None: self.config.AppendConfig('cyclictest', { "interval":self.cmd_options.cyclictest_interval }) if self.cmd_options.cyclictest_distance != None: self.config.AppendConfig('cyclictest', { "distance":self.cmd_options.cyclictest_distance }) if self.cmd_options.cyclictest_buckets != None: self.config.AppendConfig('cyclictest', { "buckets":self.cmd_options.cyclictest_distance }) if self.cmd_options.cyclictest_priority != None: self.config.AppendConfig('cyclictest', { "priority":self.cmd_options.cyclictest_priority }) if self.cmd_options.hackbench_jobspercore != None: self.config.AppendConfig('hackbench', { "jobspercore":self.cmd_options.hackbench_jobspercore }) if self.cmd_options.kcompile_jobspercore != None: self.config.AppendConfig('kcompile', { "jobspercore":self.cmd_options.kcompile_jobspercore }) self.debug("workdir: %s" % self.workdir) # prepare a mailer, if that's configured if self.config.HasSection('smtp'): self.mailer = rtevalMailer.rtevalMailer(self.config.GetSection('smtp')) else: self.mailer = None self.loads = [] self.cputopology = None self.numcores = None self.memsize = None self.current_clocksource = None self.available_clocksource = None self.services = None self.kthreads = None self.xml = None self.baseos = "unknown" self.annotate = self.cmd_options.annotate if not self.config.xslt_report.startswith(self.config.installdir): self.config.xslt_report = os.path.join(self.config.installdir, "rteval_text.xsl") if not os.path.exists(self.config.xslt_report): raise RuntimeError, "can't find XSL template (%s)!" % self.config.xslt_report # Add rteval directory into module search path sys.path.insert(0, '%s/rteval' % sysconfig.get_python_lib()) # generate a set of "junk" characters to use for filtering later self.junk = "" for c in range(0, 0xff): s = chr(c) if s not in string.printable: self.junk += s self.transtable = string.maketrans("", "") # If --xmlrpc-submit is given, check that we can access the server res = None if self.config.xmlrpc: self.debug("Checking if XML-RPC server '%s' is reachable" % self.config.xmlrpc) attempt = 0 warning_sent = False ping_failed = False while attempt < 6: try: client = rtevalclient.rtevalclient("http://%s/rteval/API1/" % self.config.xmlrpc) res = client.Hello() attempt = 10 ping_failed = False except xmlrpclib.ProtocolError: # Server do not support Hello(), but is reachable self.info("Got XML-RPC connection with %s but it did not support Hello()" % self.config.xmlrpc) res = None except socket.error, err: self.info("Could not establish XML-RPC contact with %s\n%s" % (self.config.xmlrpc, str(err))) if (self.mailer is not None) and (not warning_sent): self.mailer.SendMessage("[RTEVAL:WARNING] Failed to ping XML-RPC server", "Server %s did not respond. Not giving up yet." % self.config.xmlrpc) warning_sent = True # Do attempts handling attempt += 1 if attempt > 5: break # To avoid sleeping before we abort print "Failed pinging XML-RPC server. Doing another attempt(%i) " % attempt time.sleep(attempt*15) # Incremental sleep - sleep attempts*15 seconds ping_failed = True if ping_failed: if not self.cmd_options.xmlrpc_noabort: print "ERROR: Could not reach XML-RPC server '%s'. Aborting." % self.config.xmlrpc sys.exit(2) else: print "WARNING: Could not ping the XML-RPC server. Will continue anyway." if res: self.info("Verified XML-RPC connection with %s (XML-RPC API version: %i)" % (res["server"], res["APIversion"])) self.debug("Recieved greeting: %s" % res["greeting"])
def __init__(self, port): self.client = rtevalclient.rtevalclient( "http://localhost:%s/rteval/API1/" % port)
def __init__(self, host, logger, mailer=None): self.__host = host self.__url = "http://%s/rteval/API1/" % self.__host self.__logger = logger self.__mailer = mailer self.__client = rtevalclient.rtevalclient(self.__url)
def __init__(self, port): self.client = rtevalclient.rtevalclient("http://localhost:%s/rteval/API1/" % port)
# including keys needed to generate an equivalently functional executable # are deemed to be part of the source code. # import sys import libxml2 import io sys.path.append('../rteval') import rtevalclient print("** Creating doc") d = libxml2.newDoc("1.0") n = libxml2.newNode('TestNode1') d.setRootElement(n) n2 = n.newTextChild(None, 'TestNode2', 'Just a little test') n2.newProp('test', 'true') for i in range(1, 5): n2 = n.newTextChild(None, 'TestNode3', 'Test line %i' % i) print("** Doc to be sent") d.saveFormatFileEnc('-', 'UTF-8', 1) print("** Testing API") client = rtevalclient.rtevalclient("http://localhost:65432/rteval/API1/") print("** 1: Hello(): %s" % str(client.Hello())) status = client.SendReport(d) print("** 2: SendReport(xmlDoc): %s" % str(status))
# import sys import libxml2 import StringIO sys.path.append('../rteval') import rtevalclient print "** Creating doc" d = libxml2.newDoc("1.0") n = libxml2.newNode('TestNode1') d.setRootElement(n) n2 = n.newTextChild(None, 'TestNode2','Just a little test') n2.newProp('test','true') for i in range(1,5): n2 = n.newTextChild(None, 'TestNode3', 'Test line %i' %i) print "** Doc to be sent" d.saveFormatFileEnc('-','UTF-8', 1) print "** Testing API" client = rtevalclient.rtevalclient("http://localhost:65432/rteval/API1/") print "** 1: Hello(): %s" % str(client.Hello()) status = client.SendReport(d) print "** 2: SendReport(xmlDoc): %s" % str(status)
def __init__(self, host, logger, mailer = None): self.__host = host self.__url= "http://%s/rteval/API1/" % self.__host self.__logger = logger self.__mailer = mailer self.__client = rtevalclient.rtevalclient(self.__url)