コード例 #1
0
ファイル: trigger.py プロジェクト: blezek/TACTIC
 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()
コード例 #2
0
 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()
コード例 #3
0
ファイル: cache_startup.py プロジェクト: 0-T-0/TACTIC
    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")
コード例 #4
0
            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()
コード例 #5
0
    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")
コード例 #6
0
ファイル: cache_startup.py プロジェクト: 0-T-0/TACTIC
            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()
コード例 #7
0
            def execute(self):
                start = time.time()
                #Batch()

                #print "refresh caches ..."
                caches = CacheContainer.get_all_caches()
                for key, cache in caches.items():
                    #print "... %s" % key, cache
                    cache.init_cache()
                #print "... %s seconds" % (time.time() - start)

                DbContainer.commit_thread_sql()
                DbContainer.close_all()
コード例 #8
0
ファイル: cache_startup.py プロジェクト: mincau/TACTIC
            def execute(self):
                start = time.time()
                #Batch()

                #print "refresh caches ..."
                caches = CacheContainer.get_all_caches()
                for key, cache in caches.items():
                    #print "... %s" % key, cache
                    cache.init_cache()
                #print "... %s seconds" % (time.time() - start)

                DbContainer.commit_thread_sql()
                DbContainer.close_all()
コード例 #9
0
    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")
コード例 #10
0
            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')
コード例 #11
0
ファイル: cache_startup.py プロジェクト: 0-T-0/TACTIC
                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')