示例#1
0
    def add_rpc_datasources_timers(self):
        spacing = self.conf.datasources.snapshots_interval
        rpc_client = ds_rpc.create_rpc_client_instance(self.conf)

        @periodics.periodic(spacing=spacing)
        def get_all_periodic():
            try:
                ds_rpc.get_all(rpc_client,
                               self.events_coordination,
                               self.conf.datasources.types,
                               DatasourceAction.SNAPSHOT)
            except Exception as e:
                LOG.exception('get_all_periodic failed %s', e)

        self.periodic.add(get_all_periodic)
        LOG.info("added get_all_periodic (spacing=%s)", spacing)

        driver_names = utils.get_pull_drivers_names(self.conf)
        for d_name in driver_names:
            spacing = self.conf[d_name].changes_interval
            rpc_client = ds_rpc.create_rpc_client_instance(self.conf)

            @periodics.periodic(spacing=spacing)
            def get_changes_periodic(driver_name=d_name):
                try:
                    ds_rpc.get_changes(rpc_client,
                                       self.events_coordination,
                                       driver_name)
                except Exception as e:
                    LOG.exception('get_changes_periodic %s failed %s',
                                  driver_name, e)

            self.periodic.add(get_changes_periodic)
            LOG.info("added get_changes_periodic %s (spacing=%s)",
                     d_name, spacing)
示例#2
0
    def start_periodic_tasks(self, immediate_get_all):
        thread_num = len(utils.get_pull_drivers_names(self.conf))
        thread_num += 2  # for consistency and get_all
        self.periodic = periodics.PeriodicWorker.create(
            [],
            executor_factory=lambda: ThreadPoolExecutor(max_workers=thread_num
                                                        ))

        self._add_consistency_timer()
        self._add_datasource_timers(immediate_get_all)
        spawn(self.periodic.start)
示例#3
0
    def _add_datasource_timers(self, run_immediately):
        spacing = self.conf.datasources.snapshots_interval

        @periodics.periodic(spacing=spacing, run_immediately=run_immediately)
        def get_all_periodic():
            self.driver_exec.snapshot_get_all(DatasourceAction.SNAPSHOT)

        self.periodic.add(get_all_periodic)
        LOG.info("added get_all_periodic (spacing=%s)", spacing)

        driver_names = utils.get_pull_drivers_names(self.conf)
        for d_name in driver_names:
            spacing = self.conf[d_name].changes_interval

            @periodics.periodic(spacing=spacing)
            def get_changes_periodic():
                self.driver_exec.get_changes(d_name)

            self.periodic.add(get_changes_periodic)
            LOG.info("added get_changes_periodic %s (spacing=%s)", d_name,
                     spacing)
示例#4
0
 def test_datasource_update_method_pull(self):
     driver_names = ds_utils.get_pull_drivers_names()
     self.assertSequenceEqual(
         set([NAGIOS_DATASOURCE, ZABBIX_DATASOURCE_PULL]),
         set(driver_names))