示例#1
0
 def __init__(self, cfg):
     self._db = DatabaseServer(cfg)
     self._status = StatusServer(cfg)
     self._log = logging.getLogger(cfg.get("loggers", "RPCServer"))
示例#2
0
class RPCServer:
    # Currently all subservers are used by delegating calls to them.

    def __init__(self, cfg):
        self._db = DatabaseServer(cfg)
        self._status = StatusServer(cfg)
        self._log = logging.getLogger(cfg.get("loggers", "RPCServer"))

    def hello(self):
        "Test method to check that server is working fine."
        self._log.info("Method: hello")
        msg = "Hello you too! This is XML-RPC server for kts46."
        return msg

    # Database functions.
    def getNewJobId(self, projectName):
        self._log.info("Method: getNewJobId %s", projectName)
        return self._db.getNewJobId(projectName)

    def createProject(self, projectName):
        self._log.info("Method: createProject %s", projectName)
        self._db.createProject(projectName)

    def projectExists(self, projectName):
        self._log.info("Method: projectExists %s", projectName)
        return self._db.projectExists(projectName)

    def deleteProject(self, projectName):
        self._log.info("Method: deleteProject %s", projectName)
        self._db.deleteProject(projectName)

    def addJob(self, projectName, jobName, definition):
        self._log.info("Method: addJob %s %s ...", projectName, jobName)
        try:
            self._db.addJob(projectName, jobName, definition)
        except NameError as ex:
            self._log.error("Couldn't add job: %s", ex)
            traceback.print_exc()
            raise

    def jobExists(self, projectName, jobName):
        self._log.info("Method: jobExists %s %s", projectName, jobName)
        return self._db.jobExists(projectName, jobName)

    def deleteJob(self, projectName, jobName):
        self._log.info("Method: deleteJob %s %s", projectName, jobName)
        self._db.deleteJob(projectName, jobName)

    def getJobStatus(self, project, job):
        self._log.info("Method: getJobStatus %s %s", project, job)
        return self._status.getJobStatus(project, job)

    def getJobsList(self, project):
        self._log.info("Method: getJobsList %s", project)
        return self._status.getJobsList(project)

    def getProjectStatus(self, project):
        self._log.info("Method: getProjectStatus %s", project)
        return self._status.getProjectStatus(project)

    def getServerStatus(self):
        self._log.debug("Method: getServerStatus")
        try:
            return self._status.getServerStatus()
        except AttributeError as ex:
            self._log.error("Method `getServerStatus`: " + str(ex))
            return []

    def getJobStatistics(self, project, job, includeIdleTimes):
        self._log.debug("Method getJobStatistics %s %s", project, job)
        try:
            return self._status.getJobStatistics(project, job, includeIdleTimes)
        except KeyError:
            self._log.error("getJobStatistics: invalid project or job name: %s, %s.", project, job)
            return {}

    def getModelDescription(self, project, job):
        return self._status.getModelDescription(project, job)

    def getModelState(self, project, job, time):
        return self._status.getModelState(project, job, time)