def insert_network(self, start_number, end_number, nodes_count): network = self.get_network(start_number, end_number) if network: g_logger.critical("Exists! Returning %s" % network) return network[0][0] self.db_conn.execute("INSERT INTO networks (" "start_number, end_number, " "nodes_count, created_at, updated_at) " "values (%d, %d, %d, %d, %d)" % (start_number, end_number, nodes_count, int(time.time()), int(time.time()))) self.db_conn.commit() network = self.get_network(start_number, end_number) return network[0][0]
def insert_network(self, start_number, end_number, nodes_count): network = self.get_network(start_number, end_number) if network: g_logger.critical("Exists! Returning %s" % network) return network[0][0] self.db_conn.execute( "INSERT INTO networks (" "start_number, end_number, " "nodes_count, created_at, updated_at) " "values (%d, %d, %d, %d, %d)" % (start_number, end_number, nodes_count, int(time.time()), int(time.time())) ) self.db_conn.commit() network = self.get_network(start_number, end_number) return network[0][0]
def add_report(self, report): """ Task scheduler calls this callback """ g_logger.debug("call add report is%s" % report) # check if in the cache if report is None: g_logger.critical("Received None as report. Please, investigate.") return if report.header.reportID in self.cached_reports: g_logger.info("ReportID '%s' already in cache." % report.header.reportID) return # check if in the db if g_db_helper.select("select * from reports where report_id='%s'" % \ report.header.reportID): g_logger.info("ReportID '%s' already in db." % report.header.reportID) return report_entry = ReportEntry() # required fields report_entry.SourceID = report.header.agentID report_entry.TimeGen = report.header.timeUTC report_entry.TestID = report.header.testID report_entry.ID = report.header.reportID report_entry.Report = report # optional fields #report_entry.SourceIP = report.header.passedNode[0] self.cached_reports[report_entry.ID] = report_entry self.save_report_to_db('unsent_reports', report_entry) theApp.statistics.reports_total = theApp.statistics.reports_total + 1 theApp.statistics.reports_in_queue = \ theApp.statistics.reports_in_queue + 1
def add_report(self, report): """ Task scheduler calls this callback """ g_logger.debug("call add report is%s"%report) # check if in the cache if report is None: g_logger.critical("Received None as report. Please, investigate.") return if report.header.reportID in self.cached_reports: g_logger.info("ReportID '%s' already in cache." % report.header.reportID) return # check if in the db if g_db_helper.select("select * from reports where report_id='%s'" % \ report.header.reportID): g_logger.info("ReportID '%s' already in db." % report.header.reportID) return report_entry = ReportEntry() # required fields report_entry.SourceID = report.header.agentID report_entry.TimeGen = report.header.timeUTC report_entry.TestID = report.header.testID report_entry.ID = report.header.reportID report_entry.Report = report # optional fields #report_entry.SourceIP = report.header.passedNode[0] self.cached_reports[report_entry.ID] = report_entry self.save_report_to_db('unsent_reports', report_entry) theApp.statistics.reports_total = theApp.statistics.reports_total + 1 theApp.statistics.reports_in_queue = \ theApp.statistics.reports_in_queue + 1
def _check_aggregator_errback(self, messgae): g_logger.critical("Failed to check aggregator: %s" % message)