Esempio n. 1
0
 def run(self, plugin, pluginArgs):
     """Run the workload in a separate thread. Signal the condvar when
        done. Run platfrom plugin with run command when neccesary."""
     global splock
     additionalRunVars = None
     if self.platform.callRunSet():
         plr = PlatformReservation(self.workerDir, self.rundir, self.id,
                                   self.used)
         with splock:
             plugin_retmsg = plugin.run(".", "run", pluginArgs,
                                        plr.printXML())
         if plugin_retmsg[0] != 0:
             log.error("Platform plugin failed: %s" % plugin_retmsg[1])
             raise WorkloadError("Platform plugin failed: %s" %
                                 plugin_retmsg[1])
         log.debug("Platform plugin, run cmd: '%s'" % plugin_retmsg[1])
         rvr = RunVarReader()
         rvr.readString(plugin_retmsg[1], "Run vars from platform plugin")
         additionalRunVars = rvr.getRunVars()
     cmdstring = self.expandCmdString(additionalRunVars)
     log.debug("Full command string: %s" % cmdstring)
     with self.condVar:
         self.args = shlex.split(str(cmdstring))
         if self.running:
             raise cpc.util.CpcError("workload already running.")
         self.running = True
     # start the thread in which to run.
     th = threading.Thread(target=runThreadFn, args=(self, ))
     th.daemon = True
     th.start()
Esempio n. 2
0
 def run(self, plugin, pluginArgs):
     """Run the workload in a separate thread. Signal the condvar when
        done. Run platfrom plugin with run command when neccesary."""
     global splock
     additionalRunVars=None
     if self.platform.callRunSet():
         plr=PlatformReservation(self.workerDir, self.rundir, self.id,
                                 self.used)
         with splock:
             plugin_retmsg=plugin.run(".", "run", pluginArgs, plr.printXML())
         if plugin_retmsg[0] != 0:
             log.error("Platform plugin failed: %s"%plugin_retmsg[1])
             raise WorkloadError("Platform plugin failed: %s"%
                                 plugin_retmsg[1])
         log.debug("Platform plugin, run cmd: '%s'"%plugin_retmsg[1])
         rvr=RunVarReader()
         rvr.readString(plugin_retmsg[1], "Run vars from platform plugin")
         additionalRunVars=rvr.getRunVars()
     cmdstring=self.expandCmdString(additionalRunVars)
     log.debug("Full command string: %s"%cmdstring)
     with self.condVar:
         self.args=shlex.split(str(cmdstring))
         if self.running:
             raise cpc.util.CpcError("workload already running.")
         self.running=True
     # start the thread in which to run.
     th=threading.Thread(target=runThreadFn, args=(self,))
     th.daemon=True
     th.start()
Esempio n. 3
0
 def _getPlatforms(self, plugin):
     """Get the list of platforms als an XML string from the run plugin."""
     # make an empty platform reservation
     plr = PlatformReservation(self.mainDir)
     plugin_retmsg = plugin.run(".", "platform", self.args, str(plr.printXML()))
     if plugin_retmsg[0] != 0:
         log.error("Platform plugin failed: %s" % plugin_retmsg[1])
         raise WorkerError("Platform plugin failed: %s" % plugin_retmsg[1])
     log.debug("From platform plugin, platform cmd: '%s'" % plugin_retmsg[1])
     pfr = cpc.command.PlatformReader()
     # we also parse it for later.
     pfr.readString(plugin_retmsg[1], ("Platform description from platform plugin %s" % plugin.name))
     platforms = pfr.getPlatforms()
     return platforms
Esempio n. 4
0
 def finish(self, plugin, pluginArgs):
     """Run the platform plugin with finish when needed."""
     global splock
     if self.platform.callFinishSet():
         plr = PlatformReservation(self.workerDir, self.rundir, self.id,
                                   self.used)
         with splock:
             plugin_retmsg = plugin.run(".", "finish", pluginArgs,
                                        str(plr.printXML()))
         if plugin_retmsg[0] != 0:
             log.error("Platform plugin failed: %s" % plugin_retmsg[1])
             raise cpc.worker.WorkerError("Platform plugin failed: %s" %
                                          plugin_retmsg[1])
         log.debug("Platform plugin, finish cmd: '%s'" % plugin_retmsg[1])
Esempio n. 5
0
 def finish(self, plugin, pluginArgs):
     """Run the platform plugin with finish when needed."""
     global splock
     if self.platform.callFinishSet():
         plr=PlatformReservation(self.workerDir, self.rundir, self.id,
                                 self.used)
         with splock:
             plugin_retmsg=plugin.run(".", "finish", pluginArgs, 
                                      str(plr.printXML()))
         if plugin_retmsg[0] != 0:
             log.error("Platform plugin failed: %s"%plugin_retmsg[1])
             raise cpc.worker.WorkerError("Platform plugin failed: %s"%
                                          plugin_retmsg[1])
         log.debug("Platform plugin, finish cmd: '%s'"%plugin_retmsg[1])
Esempio n. 6
0
 def _getPlatforms(self, plugin):
     """Get the list of platforms als an XML string from the run plugin."""
     # make an empty platform reservation
     plr = PlatformReservation(self.mainDir)
     plugin_retmsg = plugin.run(".", "platform", self.args,
                                str(plr.printXML()))
     if plugin_retmsg[0] != 0:
         log.error("Platform plugin failed: %s" % plugin_retmsg[1])
         raise WorkerError("Platform plugin failed: %s" % plugin_retmsg[1])
     log.debug("From platform plugin, platform cmd: '%s'" %
               plugin_retmsg[1])
     pfr = cpc.command.PlatformReader()
     # we also parse it for later.
     pfr.readString(
         plugin_retmsg[1],
         ("Platform description from platform plugin %s" % plugin.name))
     platforms = pfr.getPlatforms()
     return platforms