def execute(my): from pyasm.biz import CacheContainer print "running cache trigger" search_type = my.input.get("search_type") assert search_type cache = CacheContainer.get(search_type) cache.make_dirty()
def execute(my): if my.mode == 'basic': return # cache sthpw tables definitions data = CacheContainer.get("sthpw_column_info") if data == None: tables = [ 'project', 'search_object', 'login', 'login_group', 'login_in_group', 'snapshot', 'file', 'trigger', 'notification', 'ticket' ] kwargs = { "key": 'sthpw_column_info', "database": 'sthpw', "tables": tables, } cache = TableInfoCache(**kwargs) # cache search object table search_type_cache = SearchTypeCache.get("sthpw/search_object") search_type_cache.build_cache_by_column("search_type") # cache login table search_type_cache = SearchTypeCache.get("sthpw/login") search_type_cache.build_cache_by_column("login") # cache login_group table search_type_cache = SearchTypeCache.get("sthpw/login_group") search_type_cache.build_cache_by_column("login_group")
def execute(my): if my.mode == 'basic': return # cache sthpw tables definitions from pyasm.security import Site site = Site.get_site() if site: key = "%s:sthpw_column_info" % site else: key = "sthpw_column_info" data = CacheContainer.get(key) if data == None: tables = ['project', 'search_object', 'login', 'login_group', 'login_in_group','snapshot','file','trigger','notification','ticket'] kwargs = { "key": key, "database": 'sthpw', "tables": tables, } cache = TableInfoCache( **kwargs ) # cache search object table search_type_cache = SearchTypeCache.get("sthpw/search_object") search_type_cache.build_cache_by_column("search_type") # cache login table search_type_cache = SearchTypeCache.get("sthpw/login") search_type_cache.build_cache_by_column("login") # cache login_group table search_type_cache = SearchTypeCache.get("sthpw/login_group") search_type_cache.build_cache_by_column("login_group")
def execute(my): #Batch() dirty_caches = CacheContainer.get_dirty() for dirty_cache in dirty_caches: key = dirty_cache.get_value("key") #print "... caching: ", key cache = CacheContainer.get(key) if not cache: print "WARNING: cache [%s] does not exist in memory" % key continue cache.init_cache() DbContainer.commit_thread_sql() DbContainer.close_all()
def execute(self): if self.mode == 'basic': return # cache sthpw tables definitions from pyasm.security import Site site = Site.get_site() if site: key = "%s:sthpw_column_info" % site else: key = "sthpw_column_info" data = CacheContainer.get(key) if data == None: tables = [ 'project', 'search_object', 'login', 'login_group', 'login_in_group', 'snapshot', 'file', 'trigger', 'notification', 'ticket' ] kwargs = { "key": key, "database": 'sthpw', "tables": tables, } cache = TableInfoCache(**kwargs) # cache search object table search_type_cache = SearchTypeCache.get("sthpw/search_object") search_type_cache.build_cache_by_column("search_type") # cache login table search_type_cache = SearchTypeCache.get("sthpw/login") search_type_cache.build_cache_by_column("login") # cache login_group table search_type_cache = SearchTypeCache.get("sthpw/login_group") search_type_cache.build_cache_by_column("login_group")
task = KillTacticTask() config_delay = Config.get_value("services", "process_time_alive") if config_delay: import random # put in a randomizer so that not all processes die at once delay = int(config_delay) offset = random.random() * delay - delay / 2 delay += offset seconds = int(delay * 60) print "Process will exit in [%s] seconds" % seconds scheduler.add_single_task(task, mode='sequential', delay=seconds) if __name__ == '__main__': Batch(project_code='cg') cmd = CacheStartup() cmd.execute() cmd.init_scheduler() try: import time time.sleep(600) except KeyboardInterrupt: scheduler = Scheduler.get() scheduler.stop() cache = CacheContainer.get("sthpw_column_info") print "cache value: ", cache.get_value_by_key('data', 'login')
delay += offset seconds = int(delay * 60) print "Process will exit in [%s] seconds" % seconds scheduler.add_single_task(task, mode='sequential', delay=seconds) if __name__ == '__main__': Batch(project_code='cg') cmd = CacheStartup() cmd.execute() cmd.init_scheduler() try: import time time.sleep(600) except KeyboardInterrupt: scheduler = Scheduler.get() scheduler.stop() cache = CacheContainer.get("sthpw_column_info") print "cache value: ", cache.get_value_by_key('data', 'login')