Exemplo n.º 1
0
 def __init__(self, config=None, dbengine=None, **kwargs):
     self.config = config
     self.db_engine = dbengine or get_engine(config, pool_size=20)
     self.aes = kwargs.pop('aes', None)
     redisconf = redis_conf(config)
     self.cache = kwargs.pop(
         'cache',
         CacheManager(redisconf,
                      cache_name='RadiusTaskCache-%s' % os.getpid()))
     self.db = scoped_session(
         sessionmaker(bind=self.db_engine,
                      autocommit=False,
                      autoflush=False))
     self.load_tasks()
     if not kwargs.get('standalone'):
         logger.info('start register taskd events')
         dispatch.register(log_trace.LogTrace(redis_conf(config)),
                           check_exists=True)
         if 'elasticsearch' in config:
             dispatch.register(eslogapi.EslogApi(config.elasticsearch))
         event_params = dict(dbengine=self.db_engine,
                             mcache=self.cache,
                             aes=self.aes)
         event_path = os.path.abspath(os.path.dirname(events.__file__))
         dispatch.load_events(event_path,
                              'taurusxradius.modules.events',
                              event_params=event_params)
     return
Exemplo n.º 2
0
 def __init__(self, config, dbengine, **kwargs):
     self.config = config
     self.que = deque()
     self.db_engine = dbengine or get_engine(config, pool_size=30)
     self.cache = CacheManager(redis_conf(config),
                               cache_name='SyncdCache-%s' % os.getpid())
     self.metadata = models.get_metadata(self.db_engine)
     self.tables = {
         _name: _table
         for _name, _table in self.metadata.tables.items()
     }
     self.master_bind = ZmqREPConnection(
         ZmqFactory(), ZmqEndpoint('bind', config.ha.master))
     self.master_bind.gotMessage = self.dataReceived
     self.sync_task = HaSyncTask(config, self.db_engine, self.cache)
     self.ops = {
         'add': self.do_add,
         'update': self.do_update,
         'delete': self.do_delete
     }
     self.process()
     logger.info(u'启动HA同步服务: [Master] {} ~ [Slave] {}'.format(
         self.config.ha.master, self.config.ha.slave))
     if not kwargs.get('standalone'):
         self.logtrace = log_trace.LogTrace(redis_conf(config))
         if 'elasticsearch' in config:
             dispatch.register(eslogapi.EslogApi(config.elasticsearch))
Exemplo n.º 3
0
def run_worker(config, dbengine, service = None, **kwargs):
    _cache = kwargs.pop('cache', CacheManager(redis_conf(config), cache_name='RadiusWorkerCache-%s' % os.getpid()))
    if not kwargs.get('standalone'):
        logger.info('start register radiusd events')
        dispatch.register(log_trace.LogTrace(redis_conf(config)), check_exists=True)
        if 'elasticsearch' in config:
            dispatch.register(eslogapi.EslogApi(config.elasticsearch))
        event_params = dict(dbengine=dbengine, mcache=_cache, aes=kwargs.pop('aes', None))
        event_path = os.path.abspath(os.path.dirname(taurusxradius.modules.events.__file__))
        dispatch.load_events(event_path, 'taurusxradius.modules.events', event_params=event_params)
    auth_worker = RADIUSAuthWorker(config, dbengine, radcache=_cache)
    acct_worker = RADIUSAcctWorker(config, dbengine, radcache=_cache)
    return
Exemplo n.º 4
0
 def __init__(self, config, dbengine=None, **kwargs):
     self.dbengine = dbengine
     self.config = config
     self.mcache = redis_cache.CacheManager(redis_conf(config),
                                            cache_name='Portald')
     self.actions = {huawei.NTF_LOGOUT: self.doAckNtfLogout}
     reactor.callLater(3.0, self.init_task)
Exemplo n.º 5
0
 def __init__(self, config = None, dbengine = None, **kwargs):
     self.config = config
     settings = dict(cookie_secret='12oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=', login_url='/admin/login', template_path=os.path.join(os.path.dirname(taurusxradius.__file__), 'views'), static_path=os.path.join(os.path.dirname(taurusxradius.__file__), 'static'), xsrf_cookies=True, config=self.config, debug=self.config.system.debug, xheaders=True)
     self.tp_lookup = TemplateLookup(directories=[settings['template_path']], default_filters=['decode.utf8', 'h'], input_encoding='utf-8', output_encoding='utf-8', encoding_errors='ignore', module_directory='/var/taurusxr/free_module_manage')
     self.license = storage.Storage(dict(sid=tools.get_sys_uuid(), type='taurusxee', create_at='2017-01-01', expire='3000-12-30'))
     os.environ['LICENSE_TYPE'] = 'taurusxee'
     self.db_engine = dbengine or get_engine(config)
     self.db = scoped_session(sessionmaker(bind=self.db_engine, autocommit=False, autoflush=False))
     redisconf = redis_conf(config)
     self.logtrace = log_trace.LogTrace(redisconf)
     self.session_manager = redis_session.SessionManager(redisconf, settings['cookie_secret'], 3600)
     self.mcache = kwargs.get('cache', CacheManager(redisconf, cache_name='RadiusManageCache-%s' % os.getpid()))
     batchsize = 32 if self.config.database.dbtype == 'sqlite' else 500
     self.db_backup = DBBackup(models.get_metadata(self.db_engine), excludes=['tr_online',
      'system_session',
      'system_cache',
      'tr_ticket',
      'tr_billing'], batchsize=batchsize)
     self.aes = kwargs.get('aes', utils.AESCipher(key=self.config.system.secret))
     self.init_superrpc()
     dispatch.register(self.mcache)
     dispatch.register(self.logtrace)
     if 'elasticsearch' in self.config:
         dispatch.register(eslogapi.EslogApi(self.config.elasticsearch))
     self.mpsapi = None
     self.wechat = None
     self.init_handlers()
     self.init_events()
     cyclone.web.Application.__init__(self, permit.all_handlers, **settings)
     return
Exemplo n.º 6
0
 def __init__(self, config=None, dbengine=None, **kwargs):
     self.config = config
     os.environ['LICENSE_TYPE'] = 'taurusxee'
     settings = dict(
         cookie_secret='12oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
         login_url='/usrportal/login',
         template_path=os.path.join(os.path.dirname(taurusxradius.__file__),
                                    'views'),
         static_path=os.path.join(os.path.dirname(taurusxradius.__file__),
                                  'static'),
         xsrf_cookies=True,
         config=self.config,
         debug=self.config.system.debug,
         xheaders=True)
     self.tp_lookup = TemplateLookup(
         directories=[settings['template_path']],
         default_filters=['decode.utf8', 'h'],
         input_encoding='utf-8',
         output_encoding='utf-8',
         encoding_errors='ignore',
         module_directory='/var/taurusxr/module_usrportal')
     self.db_engine = dbengine or get_engine(config)
     self.db = scoped_session(
         sessionmaker(bind=self.db_engine,
                      autocommit=False,
                      autoflush=False))
     redisconf = redis_conf(config)
     self.logtrace = log_trace.LogTrace(redisconf)
     self.session_manager = redis_session.SessionManager(
         redisconf, settings['cookie_secret'], 3600)
     self.mcache = kwargs.get(
         'cache',
         CacheManager(redisconf, cache_name='UsrpdCache-%s' % os.getpid()))
     self.paycache = CacheManager(redisconf,
                                  cache_name='UsrpdPayCache-%s' %
                                  os.getpid(),
                                  db=9)
     self.aes = kwargs.get('aes',
                           utils.AESCipher(key=self.config.system.secret))
     logger.info('start register usrportal events')
     dispatch.register(self.mcache)
     dispatch.register(self.logtrace)
     if 'elasticsearch' in config:
         dispatch.register(eslogapi.EslogApi(config.elasticsearch))
     load_handlers(handler_path=os.path.join(
         os.path.abspath(os.path.dirname(__file__)), 'usrportal'),
                   pkg_prefix='taurusxradius.modules.usrportal',
                   excludes=['webserver', 'radius'])
     cyclone.web.Application.__init__(self, permit.all_handlers, **settings)