예제 #1
0
파일: master.py 프로젝트: maximerobin/Ufwi
    def connection_success(self, success, job):
        """
        Connection with firewall is successfull, so we result True to
        admin client, and schedule the request starting.
        """

        firewall = Firewall(self, self.core, self.NAME, job.name, {'state':Firewall.REGISTERING, 'last_seen':0, 'hostname' : job.hostname})
        self.firewalls[job.name] = firewall
        job.firewall = firewall
        scheduleOnce(0, self.start_request, job)
        return True
예제 #2
0
 def init_done(self):
     self.states_path = os.path.join(
         self.core.config.get("CORE", "vardir"), "supervisor.xml")
     try:
         self.states.load(self.states_path)
     except ConfigError:
         for reaction_function in reaction_functions:
             self.states.set(reaction_function.__name__, 0)
     # Launch the first check in 10 seconds. The callback function will
     # schedule itself with a delay of delay_seconds seconds at the end of
     # its body.
     scheduleOnce(10, self.check_and_react)
예제 #3
0
파일: master.py 프로젝트: maximerobin/Ufwi
    def loadConfig(self):
        """
        Load configuration of PKI, OpenVPN and firewalls.
        """

        d = succeed("done")
        d.addCallback(self.pki.loadPki)
        d.addCallback(self.setFirewallRules)
        d.addCallback(self.createOpenVPNCertificate)
        d.addCallback(self.loadCategories)
        d.addCallback(self.loadFirewalls)
        d.addCallback(lambda x: scheduleOnce(3, self.loadTransport))
        d.addErrback(self.loadError)
        return d
예제 #4
0
파일: task.py 프로젝트: maximerobin/Ufwi
    def reschedule(self, sched_options):
        self.task_retry_time = sched_options["retry_time"]
        self.sched_options = sched_options
        if self.task_retry_time < 5:
            self.task_retry_time = 5
        self.task_stop_on_success = sched_options["stop_on_success"]

        start_date = sched_options["start_date"]
        if start_date != 0:
            start_date = start_date - time.time()
            now = datetime.datetime.now()
            now += datetime.timedelta(seconds=start_date)
            self.status = tr(u"Starting on %s") % now.strftime("%x %X")
        else:
            self.sched_options["start_date"] = time.time()

        if start_date <= 0:
            self.firstStart()
        else:
            self.delayed_task = scheduleOnce(start_date, self.firstStart)
예제 #5
0
파일: primary.py 프로젝트: maximerobin/Ufwi
 def scheduleHello(self, sleep_time):
     if self.hello_task_id is not None:
         self.hello_task_id.cancel()
     self.debug('schedule call to hello on primary node (%s)' % sleep_time)
     self.hello_task_id = scheduleOnce(sleep_time, self.hello)
예제 #6
0
파일: primary.py 프로젝트: maximerobin/Ufwi
 def checkTransport(self, status):
     if not status:
         scheduleOnce(self.TRANSPORT_INTERVAL, self.startTransport)
예제 #7
0
    @inlineCallbacks
    def check_and_react(self, manual_purge=False):
        yield deferToThread(self._check_and_react, manual_purge)
        try:
            if self.registered_for_mail.new_alerts:
                body = self.registered_for_mail.make_body()
                context = Context.fromComponent(self)
                yield self.core.callService(context, 'contact', 'sendMailToAdmin',
                                      subjects.get(self.config.language,
                                                   subjects["en"]),
                                      body)
        except Exception, err:
            self.writeError(err, "Error while sending alert e-mail")

        if not manual_purge:
            scheduleOnce(delay_seconds, self.check_and_react)

    def _check_and_react(self, manual_purge=False):
        self.purging = True
        system_data = data_gatherer(self)
        self.registered_for_mail.clear()
        self._execute_reactions(system_data, manual_purge)
        self.purging = False

    ############
    # Services #
    ############

    def service_purge(self, context):
        if self.purging:
            return False