Ejemplo n.º 1
0
    def __init__(self, items=()):
        EventBus.__init__(self)
        self.deq = collections.deque()
        self.lock = threading.Lock()
        self.event = threading.Event()

        self.onfini( self._onQueFini )
Ejemplo n.º 2
0
    def __init__(self):
        EventBus.__init__(self)
        self.threads = {}

        self.on('thread:init', self._initThread)
        self.on('thread:fini', self._finiThread)
        self.onfini(self._finiThreadBoss)
Ejemplo n.º 3
0
    def __init__(self, queen, **config):
        # NOTE: queen must *always* be a telepath proxy

        EventBus.__init__(self)

        self.iden = guid()

        self.slots = {}
        self.slocs = {}

        self.queen = queen
        self.config = config

        # FIXME maybe put our hostname etc in config?

        self.queen.on('tele:sock:init', self._onTeleSockInit )
        self.queen.on('hive:tell:%s' % self.iden, self._onHiveTell)

        self.localurl = 'local://%s/syn.queen' % self.iden

        # each worker has a local:// daemon
        self.dmon = s_daemon.Daemon()
        self.dmon.listen(self.localurl)

        self.dmon.share('syn.queen',queen)

        self.on('hive:slot:run', self._onHiveSlotRun)
        self.on('hive:slot:fini', self._onHiveSlotFini)

        self._initQueenProxy()
Ejemplo n.º 4
0
    def __init__(self, queen, **config):
        # NOTE: queen must *always* be a telepath proxy

        EventBus.__init__(self)

        self.iden = s_common.guid()

        self.slots = {}
        self.slocs = {}

        self.queen = queen
        self.config = config

        # FIXME maybe put our hostname etc in config?

        self.queen.on('tele:sock:init', self._onTeleSockInit)
        self.queen.on('hive:tell:%s' % self.iden, self._onHiveTell)

        self.localurl = 'local://%s/syn.queen' % self.iden

        # each worker has a local:// daemon
        self.dmon = s_daemon.Daemon()
        self.dmon.listen(self.localurl)

        self.dmon.share('syn.queen', queen)

        self.on('hive:slot:run', self._onHiveSlotRun)
        self.on('hive:slot:fini', self._onHiveSlotFini)

        self._initQueenProxy()
Ejemplo n.º 5
0
    def __init__(self):
        EventBus.__init__(self)
        self.threads = {}

        self.on('thread:init', self._initThread)
        self.on('thread:fini', self._finiThread)
        self.onfini(self._finiThreadBoss)
Ejemplo n.º 6
0
    def __init__(self, core):

        EventBus.__init__(self)
        self.core = core

        self.keys = c_cache.Cache()
        self.keys.setOnMiss( self._getRsaKey )

        self.pubs = c_cache.Cache()
        self.pubs.setOnMiss( self._getPubKey )

        self.certs = c_cache.Cache()
        self.certs.setOnMiss( self._getTokenCert )

        self.tokens = c_cache.Cache()
        self.tokens.setOnMiss( self._getTokenTufo )

        core.onfini( self.keys.fini )
        core.onfini( self.pubs.fini )
        core.onfini( self.certs.fini )
        core.onfini( self.tokens.fini )

        core.addTufoForm('syn:token', ptype='str', doc='synapse identity token (user/host)')

        core.addTufoProp('syn:token', 'user', doc='humon readable user name for this token')
        core.addTufoProp('syn:token', 'host', doc='humon readable host name for this token')

        core.addTufoProp('syn:token', 'blob', doc='Base64 encoded token blob')
        core.addTufoProp('syn:token', 'cert', doc='Base64 encoded certificate blob')
        core.addTufoProp('syn:token', 'rsakey', doc='base64( der( rsa.private ) )')
Ejemplo n.º 7
0
    def __init__(self, func, *args, **kwargs):
        EventBus.__init__(self)

        threading.Thread.__init__(self)
        self.setDaemon(True)

        self.iden = s_common.guid()
        self.task = (func, args, kwargs)
Ejemplo n.º 8
0
    def __init__(self, cura, iden, **props):
        EventBus.__init__(self)

        self.iden = iden
        self.cura = cura
        self.props = props

        self.on('sess:log', self.cura.dist)
Ejemplo n.º 9
0
    def __init__(self, items=()):
        EventBus.__init__(self)
        self.deq = collections.deque()
        self.lock = threading.Lock()
        self.event = threading.Event()

        self._que_done = False
        self.onfini(self.event.set)
Ejemplo n.º 10
0
    def __init__(self, cura, sess):
        EventBus.__init__(self)

        self.sid = sess[0]
        self.cura = cura
        self.sess = sess

        self.local = {}      # runtime only props
Ejemplo n.º 11
0
    def __init__(self, cura, sess):
        EventBus.__init__(self)

        self.sid = sess[0]
        self.cura = cura
        self.sess = sess

        self.local = {}  # runtime only props
Ejemplo n.º 12
0
    def __init__(self):
        EventBus.__init__(self)
        self.tagsbyname = {}
        self.coresbyname = {}

        self.coresbytag = collections.defaultdict(list)

        self.onfini( self._onMetaFini )
Ejemplo n.º 13
0
    def __init__(self, fd=None):
        EventBus.__init__(self)
        self.fd = fd
        self.last = time.time()
        self.lock = threading.Lock()

        self.items = []
        self.event = threading.Event()
        self.onfini( self._onQueFini )
Ejemplo n.º 14
0
    def __init__(self):
        EventBus.__init__(self)

        self.root = None
        self.lock = threading.Lock()
        self.wake = threading.Event()

        self.thr = self._runSchedMain()
        self.onfini( self._onSchedFini )
Ejemplo n.º 15
0
    def __init__(self, fd=None):
        EventBus.__init__(self)
        self.fd = fd
        self.last = time.time()
        self.lock = threading.Lock()

        self.items = []
        self.event = threading.Event()
        self.onfini(self._onQueFini)
Ejemplo n.º 16
0
    def __init__(self, maxsize=10000, onmiss=None):
        EventBus.__init__(self)

        self.cache = {}
        self.onmiss = onmiss
        self.maxsize = maxsize
        self.cachelock = threading.Lock()

        self.fifo = collections.deque()
Ejemplo n.º 17
0
    def __init__(self):
        EventBus.__init__(self)

        self.root = None
        self.lock = threading.Lock()
        self.wake = threading.Event()

        self.thr = self._runSchedMain()
        self.onfini(self._onSchedFini)
Ejemplo n.º 18
0
    def __init__(self, relay):
        EventBus.__init__(self)
        self.relay = relay

        self.boss = s_threads.ThreadBoss()
        self.onfini(self.boss.fini)

        # we get the sock first to fill in info
        self.on('link:sock:init', self._onLinkSockInit)
Ejemplo n.º 19
0
    def __init__(self, maxsize=10000, onmiss=None):
        EventBus.__init__(self)

        self.cache = {}
        self.onmiss = onmiss
        self.maxsize = maxsize
        self.cachelock = threading.Lock()

        self.fifo = collections.deque()
Ejemplo n.º 20
0
    def __init__(self, core=None, maxtime=onehour):
        EventBus.__init__(self)

        self.core = core

        self.cache = s_cache.Cache(maxtime=maxtime)
        self.cache.setOnMiss(self._getSessByIden)
        self.cache.on('cache:pop', self._onSessCachePop)

        self.onfini(self.cache.fini)
Ejemplo n.º 21
0
    def __init__(self):
        #cmd.Cmd.__init__(self)
        EventBus.__init__(self)

        self.cmdfuncs = {}
        self.cmdprompt = 'cli> '

        self.addCmdMeths(self)
        self.addCmdFunc(cmd_quit, name='quit')
        self.addCmdFunc(cmd_help, name='help')
Ejemplo n.º 22
0
    def __init__(self):
        #cmd.Cmd.__init__(self)
        EventBus.__init__(self)

        self.cmdfuncs = {}
        self.cmdprompt = 'cli> '

        self.addCmdMeths(self)
        self.addCmdFunc(cmd_quit, name='quit')
        self.addCmdFunc(cmd_help, name='help')
Ejemplo n.º 23
0
    def __init__(self, sock, **info):
        EventBus.__init__(self)
        self.sock = sock
        self.unpk = msgpack.Unpacker(use_list=0,encoding='utf8')
        self.ident = s_common.guid()
        self.xforms = []        # list of SockXform instances
        self.crypto = None
        self.sockinfo = info

        self.onfini(self._finiSocket)
Ejemplo n.º 24
0
    def __init__(self, info, axon=None):
        EventBus.__init__(self)
        self._i_res = {}
        self._i_info = info
        self._i_axon = axon

        self._i_glab = s_gene.GeneLab()

        self._tvar_cache = {}
        self._tvar_regex = re.compile('{{(\w+)}}')
Ejemplo n.º 25
0
    def __init__(self, core=None, maxtime=onehour):
        EventBus.__init__(self)

        self.core = core

        self.cache = s_cache.Cache(maxtime=maxtime)
        self.cache.setOnMiss( self._getSessByIden )
        self.cache.on('cache:pop', self._onSessCachePop )

        self.onfini( self.cache.fini )
Ejemplo n.º 26
0
    def __init__(self, sock, **info):
        EventBus.__init__(self)
        self.sock = sock
        self.unpk = msgpack.Unpacker(use_list=0, encoding='utf8')
        self.ident = s_common.guid()
        self.xforms = []  # list of SockXform instances
        self.crypto = None
        self.sockinfo = info

        self.onfini(self._finiSocket)
Ejemplo n.º 27
0
    def __init__(self, statefd=None):
        self.authinfo = {}
        self.authrules = collections.defaultdict(dict)

        EventBus.__init__(self)
        StateMachine.__init__(self, statefd=statefd)

        if self.getAuthInfo('defauth') == None:
            self.setAuthInfo('defauth', False)

        self._loadAuthRules()
Ejemplo n.º 28
0
    def __init__(self):
        EventBus.__init__(self)
        self.lock = threading.Lock()
        self.sched = s_sched.Sched()

        self.slots = {}

        self.hives = {}
        self.drones = {}

        self.slotq = collections.deque()
Ejemplo n.º 29
0
    def __init__(self, link):
        EventBus.__init__(self)

        self.link = link
        self.relay = s_link.initLinkRelay(link)
        self.client = self._init_client()

        self._tele_with = {}    # tid:client for with blocks

        # objname is path minus leading "/"
        self.objname = link[1].get('path')[1:]
Ejemplo n.º 30
0
    def __init__(self):
        EventBus.__init__(self)
        self.lock = threading.Lock()
        self.sched = s_sched.Sched()

        self.slots = {}

        self.hives = {}
        self.drones = {}

        self.slotq = collections.deque()
Ejemplo n.º 31
0
    def __init__(self, svcbus, **opts):
        EventBus.__init__(self)
        s_storm.Runtime.__init__(self)

        self.addConfDef('svcbus:deftag', asloc='deftag', type='syn:tag', defval=deftag, doc='Default tag for cores')
        self.addConfDef('svcbus:timeout', asloc='svctime', type='int', doc='SvcBus Telepath Link Tufo')

        self.setConfOpts(opts)

        self.svcbus = svcbus
        self.svcprox = s_service.SvcProxy(svcbus, self.svctime)
Ejemplo n.º 32
0
    def __init__(self, core, maxtime=onehour):
        EventBus.__init__(self)

        self.core = core
        self.model = core.genDataModel()

        self.cache = s_cache.Cache(maxtime=maxtime)
        self.cache.setOnMiss( self._getSessBySid )
        self.cache.on('cache:pop', self._onSessCachePop )

        self.onfini( self.cache.fini )
Ejemplo n.º 33
0
    def __init__(self, core, maxtime=onehour):
        EventBus.__init__(self)

        self.core = core
        self.model = core.genDataModel()

        self.cache = s_cache.Cache(maxtime=maxtime)
        self.cache.setOnMiss(self._getSessBySid)
        self.cache.on('cache:pop', self._onSessCachePop)

        self.onfini(self.cache.fini)
Ejemplo n.º 34
0
    def __init__(self, iden=None):

        EventBus.__init__(self)

        if iden is None:
            iden = s_common.guid()

        self.info = {}
        self.iden = iden

        self.on('task:fini', self._onTaskFini)
Ejemplo n.º 35
0
    def __init__(self, statefd=None):
        self.authinfo = {}
        self.authrules = collections.defaultdict(dict)

        EventBus.__init__(self)
        StateMachine.__init__(self, statefd=statefd)

        if self.getAuthInfo('defauth') == None:
            self.setAuthInfo('defauth', False)

        self._loadAuthRules()
Ejemplo n.º 36
0
    def __init__(self, func, *args, **kwargs):
        EventBus.__init__(self)

        threading.Thread.__init__(self)
        self.setDaemon(True)

        self.iden = guid()
        self.task = (func,args,kwargs)

        self.cancels = []

        self.onfini( self._onThrFini )
Ejemplo n.º 37
0
    def __init__(self):
        EventBus.__init__(self)

        self.coreok = {}
        self.cordefs = {}
        self.tagsbyname = {}
        self.coresbyname = {}

        self.sched = s_sched.Sched()
        self.coresbytag = collections.defaultdict(list)

        self.onfini( self._onMetaFini )
Ejemplo n.º 38
0
    def __init__(self):
        EventBus.__init__(self)

        self.coreok = {}
        self.cordefs = {}
        self.tagsbyname = {}
        self.coresbyname = {}

        self.sched = s_sched.Sched()
        self.coresbytag = collections.defaultdict(list)

        self.onfini(self._onMetaFini)
Ejemplo n.º 39
0
    def __init__(self, svcbus, **opts):
        EventBus.__init__(self)

        # a core we use for data model stuff..
        self.core = s_cortex.openurl('ram:///')
        self.onfini(self.core.fini)

        s_storm.Runtime.__init__(self)
        self.setConfOpts(opts)

        self.svcbus = svcbus
        self.svcprox = s_service.SvcProxy(svcbus, self.svctime)
Ejemplo n.º 40
0
    def __init__(self, func, *args, **kwargs):
        EventBus.__init__(self)

        threading.Thread.__init__(self)
        self.setDaemon(True)

        self.iden = s_common.guid()
        self.task = (func, args, kwargs)

        self.cancels = []

        self.onfini(self._onThrFini)
Ejemplo n.º 41
0
    def __init__(self, fd, **opts):
        EventBus.__init__(self)

        fd.seek(0, os.SEEK_END)

        self.fd = fd
        self.size = fd.tell()
        self.fdoff = self.size
        self.fileno = fd.fileno()

        self.lock = threading.Lock()

        self.onfini( self._onAtomFini )
Ejemplo n.º 42
0
    def __init__(self, outp=None):
        EventBus.__init__(self)

        if outp == None:
            outp = s_output.OutPut()

        self.outp = outp

        self.cmds = {}
        self.cmdprompt = 'cli> '

        self.addCmdClass( CmdHelp )
        self.addCmdClass( CmdQuit )
Ejemplo n.º 43
0
    def __init__(self, relay):
        EventBus.__init__(self)
        self.relay = relay

        self.boss = s_threads.ThreadBoss()
        self.onfini(self.boss.fini)
        self.socks = {}

        # we get the sock first to fill in info
        self.on('link:sock:init', self._onLinkSockInit)
        self.on('link:sock:fini', self._onLinkSockFini)

        self.onfini( self._finiAllSocks )
Ejemplo n.º 44
0
    def __init__(self):
        EventBus.__init__(self)

        self.onfini(self._onBossFini)

        self.pool = None

        self.joblock = threading.Lock()

        self._boss_jobs = {}
        self.joblocal = {}

        self.on('job:done', self._onJobDone)  # trigger job done
        self.on('job:fini', self._onJobFini)  # job is finished
Ejemplo n.º 45
0
    def __init__(self, statefd=None):
        EventBus.__init__(self)

        self.authmod = None
        self.links = {}
        self.mesgmeths = {}

        self.boss = s_threads.ThreadBoss()
        self.onfini( self.boss.fini )

        s_telepath.TeleMixin.__init__(self)

        StateMachine.__init__(self,statefd=statefd)
        self.on('link:sock:mesg',self._onLinkSockMesg)
Ejemplo n.º 46
0
    def __init__(self, maxtime=None, onmiss=None):
        EventBus.__init__(self)
        self.onmiss = onmiss

        self.cache = {}
        self.lasthit = {}
        self.schevt = None
        self.maxtime = None
        self.cachelock = threading.Lock()

        self.onfini(self._onCacheFini)

        if maxtime is not None:
            self.setMaxTime(maxtime)
Ejemplo n.º 47
0
    def __init__(self, statefd=None):
        EventBus.__init__(self)

        self.authmod = None
        self.links = {}
        self.mesgmeths = {}

        self.boss = s_threads.ThreadBoss()
        self.onfini(self.boss.fini)

        s_telepath.TeleMixin.__init__(self)

        StateMachine.__init__(self, statefd=statefd)
        self.on('link:sock:mesg', self._onLinkSockMesg)
Ejemplo n.º 48
0
    def __init__(self, size=3, maxsize=None):
        EventBus.__init__(self)

        self.workq = s_queue.Queue()

        self._pool_lock = threading.Lock()
        self._pool_avail = 0
        self._pool_maxsize = maxsize

        self._pool_threads = {}

        self.onfini( self._onPoolFini )

        for i in range(size):
            self._fire_thread( self._run_work )
Ejemplo n.º 49
0
    def __init__(self):
        EventBus.__init__(self)

        self.onfini( self._onBossFini )

        self.pool = None
        self.sched = s_sched.getGlobSched()

        self.joblock = threading.Lock()

        self._boss_jobs = {}
        self.joblocal = {}

        self.on('job:done', self._onJobDone )  # trigger job done
        self.on('job:fini', self._onJobFini )  # job is finished
Ejemplo n.º 50
0
    def __init__(self, sock, **info):
        EventBus.__init__(self)

        self.sock = sock
        self.plex = None
        self.unpk = msgpack.Unpacker(use_list=0,encoding='utf8')
        self.iden = s_common.guid()
        self.xforms = []        # list of SockXform instances
        self.info = info

        # used by Plex() tx
        self.txbuf = None
        self.txque = collections.deque()

        self.onfini(self._finiSocket)
Ejemplo n.º 51
0
    def __init__(self, pool=None):

        EventBus.__init__(self)

        if pool is None:
            pool = s_threads.Pool()

        self.pool = pool
        self.root = None

        self.lock = threading.Lock()
        self.wake = threading.Event()

        self.thr = self._runSchedMain()
        self.onfini(self._onSchedFini)
Ejemplo n.º 52
0
    def __init__(self, item, outp=None, **locs):
        EventBus.__init__(self)

        if outp is None:
            outp = s_output.OutPut()

        self.outp = outp
        self.locs = locs
        self.item = item  # whatever object we are commanding

        self.cmds = {}
        self.cmdprompt = 'cli> '

        self.addCmdClass(CmdHelp)
        self.addCmdClass(CmdQuit)
Ejemplo n.º 53
0
    def __init__(self, maxtime=None, onmiss=None):
        EventBus.__init__(self)

        self.sched = s_sched.getGlobSched()
        self.onmiss = onmiss

        self.cache = {}
        self.lasthit = {}
        self.schevt = None
        self.maxtime = None
        self.cachelock = threading.Lock()

        self.onfini( self._onCacheFini )

        if maxtime != None:
            self.setMaxTime(maxtime)
Ejemplo n.º 54
0
    def __init__(self, **settings):
        EventBus.__init__(self)
        s_daemon.DmonConf.__init__(self)
        tornado.web.Application.__init__(self, **settings)

        self.loop = tornado.ioloop.IOLoop.current()
        self.serv = tornado.httpserver.HTTPServer(self)

        self.boss = s_async.Boss()

        # FIXME options
        self.boss.runBossPool(8, maxsize=128)

        self.iothr = self._runWappLoop()

        self.onfini( self._onWappFini )
Ejemplo n.º 55
0
    def __init__(self, **settings):
        EventBus.__init__(self)
        self.onfini( self._onDavFini )

        self.root = PathNode()

        self.paths = s_cache.Cache(maxtime=60)
        self.paths.setOnMiss( self._getDavNode )

        self.app = tornado.web.Application( (
            ('.*', WebDavHandler, {'webdav': self}),
        ))

        self.ioloop = tornado.ioloop.IOLoop()

        settings['io_loop'] = self.ioloop
        self.serv = tornado.httpserver.HTTPServer(self.app, **settings)
Ejemplo n.º 56
0
    def __init__(self, maxtime=None):
        EventBus.__init__(self)

        self.sched = s_sched.getGlobSched()
        self.onmiss = None

        self.cache = {}
        self.lasthit = {}
        self.cachelock = threading.Lock()

        self.onfini( self._onCacheFini )

        self.schevt = None
        self.maxtime = maxtime

        if self.maxtime != None:
            self._checkCacheTimes()
Ejemplo n.º 57
0
    def __init__(self, relay):
        EventBus.__init__(self)

        self.lock = threading.Lock()

        self.relay = relay
        self.trans = relay.link[1].get('trans')

        self.onfini(self._finiLinkClient)

        self.sock = relay.initClientSock()

        if self.sock == None:
            raise Exception('Initial Link Failed: %r' % (self.link,))

        if self.trans:
            self.sock.fini()
Ejemplo n.º 58
0
    def __init__(self, core):
        EventBus.__init__(self)

        self.core = core

        self.core.addTufoForm('syn:auth:user')
        self.core.addTufoProp('syn:auth:user','apikey', defval='')
        self.core.addTufoProp('syn:auth:user','shadow:sha256', defval='')

        self.core.addTufoForm('syn:auth:role')

        self.core.addTufoForm('syn:auth:userrole')
        self.core.addTufoProp('syn:auth:userrole','user')
        self.core.addTufoProp('syn:auth:userrole','role')

        self.users = s_cache.TufoPropCache(core,'syn:auth:user')
        self.roles = s_cache.TufoPropCache(core,'syn:auth:role')

        self.rules = s_cache.KeyCache(self._getUserRulesCache)