Exemplo n.º 1
0
Arquivo: mcp.py Projeto: rhettg/Tron
    def add_job(self, job):
        if job.name in self.services:
            raise ValueError("Job %s is already a service", job.name)
        if job.name in self.jobs:
            # Jobs have a complex eq implementation that allows us to catch jobs that have not changed and thus
            # don't need to be updated during a reconfigure
            if job == self.jobs[job.name]:
                return
            
            log.info("re-adding job %s", job.name)        
            # We're updating an existing job, we have to copy over run time information
            job.absorb_old_job(self.jobs[job.name])

            if job.enabled:
                self.disable_job(job)
                self.enable_job(job)
        else:
            log.info("adding job %s", job.name)
        
        self.jobs[job.name] = job

        job.set_context(self.context)
        job.event_recorder.set_parent(self.event_recorder)
        self.setup_job_dir(job)
        job.listen(True, self.state_handler.store_state)
Exemplo n.º 2
0
    def add_job(self, job):
        if job.name in self.jobs:
            # Jobs have a complex eq implementation that allows us to catch jobs that have not changed and thus
            # don't need to be updated during a reconfigure
            if job == self.jobs[job.name]:
                return
            
            # We're updating an existing job, we have to copy over run time information
            job.absorb_old_job(self.jobs[job.name])

            if job.enabled:
                self.disable_job(job)
                self.enable_job(job)
        
        self.jobs[job.name] = job

        job.set_context(self.context)
        self.setup_job_dir(job)
        job.state_callback = self.state_handler.store_state