Ejemplo n.º 1
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()
Ejemplo n.º 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()
Ejemplo n.º 3
0
    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")
Ejemplo n.º 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()
Ejemplo n.º 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")
Ejemplo n.º 6
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()
Ejemplo n.º 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()
Ejemplo n.º 8
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()
Ejemplo n.º 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")
Ejemplo n.º 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')
Ejemplo n.º 11
0
                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')