Ejemplo n.º 1
0
 def run(self):
     self.contractorLayer    = core.getCoreInstance().getInstance('CONTRACTOR')
     self.scheduler          = core.getCoreInstance().getInstance('SCHEDULER')
     self._revision          = 0
     self.readInfo()
     self._setReady()
     while self._running:
         time.sleep(0.5)
         self.readInfo()
Ejemplo n.º 2
0
 def run(self):
     self._taskManager   = core.getCoreInstance().getInstance('TASK_MANAGER')
     self._agentID       = core.getCoreInstance().getItem('agent')['__id']
     self._entityManager = core.getCoreInstance().getInstance('ENTITY_MANAGER')
     self._createConnection(self._server_addr, self._server_port)
     self._setReady()
     
     while(self._running):
         self._process()
         time.sleep(0.01)
Ejemplo n.º 3
0
 def run(self):
     
     self._storage       = core.getCoreInstance().getInstance('STORAGE')
     self._taskManager   = core.getCoreInstance().getInstance('TASK_MANAGER')
     self._logger.info('Scheduler started')
     self._loadStorage()
     self._setReady()
     it  = 0
     while self._running:
         self._process()
         time.sleep(CHECK_INTERVAL)
         it += CHECK_INTERVAL
         if it > STORE_INTERVAL :
             it = 0
             self._store_schedule()
Ejemplo n.º 4
0
 def __init__(self, taskManager):
     '''
     Constructor
     '''
     self._taskManager   = taskManager
     self._commands  = {}
     self._revision  = 0
     self._entityManager = core.getCoreInstance().getInstance('ENTITY_MANAGER')       
     
     '''
     config    = {
         'item-id':     {
                         '__type': type,
                         '__tags': [tags],
                         '__added': time,
                         '__revision': autoincrement number   
                         'content' : {item-content}
                         }        
                 }
     '''
     '''
     self._commands  = {'identifikator': {     '__agents': 'all', 
                                               '__add_timestamp': time.time(),\
                                               '__type':'add_scheduled_task', 
                                               'content': {
                                                            'func': 'testPrint',
                                                            'name': 'testPrint',
                                                            'interval': 5*60,
                                                            'start_time': None,
                                                            'kwargs': {'los': 'test', 't': True}
                                                           }}}
     '''
     self._current   = {}
     self._refresh   = time.time()
Ejemplo n.º 5
0
def sync(t, data):
    i       = t._parent.interfaceInstance
    recv    = i.get('cfg')
    cfg = recv['cfg']
    new_revision = recv['v']
    print("new_revision is "+str(new_revision))
    e   = core.getCoreInstance().getInstance('ENTITY_MANAGER')
    e.updateList(cfg, new_revision)
    i._logger.info("Synchronized configuration with server")
Ejemplo n.º 6
0
 def _update(self):
     self._cmd   = []
     self._st = core.getCoreInstance().getInstance('STORAGE').getInstance()
     self._st.set_default_collection('commands')
     for cmd in self._st.find({'_new': True}):
         cmd['_new']  = False
         self._st.save(cmd)
         cmd['_new'] = None
         cmd['_id'] = None
         self._cmd.append(cmd)
Ejemplo n.º 7
0
 def run(self):
     self._storage       = core.getCoreInstance().getInstance('STORAGE')
     if not os.path.exists(self.contractors_path):
         os.makedirs(self.contractors_path)
     self._load()
     self._setReady()
     self._logger.info("Layer started")
     while self._running:
         time.sleep(0.01) 
     self._logger.info("Layer stopped")
Ejemplo n.º 8
0
 def run(self):
     cr      = core.getCoreInstance()
     self._storageManager     = cr.getInstance('STORAGE')
     self._scheduler          = cr.getInstance('SCHEDULER')
     self._setReady()
     self._logger.info("Task manager started")
     while(self._running):
         if self._checkForTasks():
             self._process()
         else:
             time.sleep(0.1)
     self._logger.info('Task Manager was successfully shutdown')
Ejemplo n.º 9
0
def refreshServerStat(tm, *args):
    print('REFRESH TEST')
    st  = tm._storageManager.getInstance()
    st.set_default_collection('server')
    c   = core.getCoreInstance()
    for name, inst in c._instances.items():
        q   = {'component': name}
        stat    = {}
        for k, v in inst.items():
            stat[k] = str(v)
        doc = {'component': name, 'stat': stat}
        st.update(q, doc)
Ejemplo n.º 10
0
    def run(self):
        c = core.getCoreInstance()
        self.storageInstance = c.getInstance("STORAGE")
        self.interfaceInstance = c.getInstance("INTERFACE")
        self.contractorLayer = c.getInstance("CONTRACTOR")
        self.scheduler = c.getInstance("SCHEDULER")
        self.agentID = c.getItem("agent")["__id"]
        self._pool.start()

        self._setReady()
        self._logger.info("Task Manager started")
        while self._running:
            self._process()
        self._logger.info("Task Manager shutdown")
Ejemplo n.º 11
0
 def run(self):
     try:
         _core   = core.getCoreInstance()
         self._tmInstance    = _core.getInstance('TASK_MANAGER')
         self.cmdInterface   = interface.CommandInterface(self._tmInstance)
         agentHandler        = interface.xmlrpcHandler(self._tmInstance, self.cmdInterface)
         self._xmlrpcListener.register_instance(agentHandler)
         self._setReady()
         self._logger.info('xmlrpc listener starting')
         self._xmlrpcListener.serve_forever()
                     
     except XMLRPCExitException:
         print("xmlrpc server shutdown")
     self._logger.info('server instance with id {0} was stopped'.format(self._getId()))
Ejemplo n.º 12
0
 def _update(self):
     stManager   = core.getCoreInstance().getInstance('STORAGE')
     st          = stManager.getInstance()
     st.set_default_collection('configuration')
     self._config = []
     for item in st.find({}):
         if item['__type'] == 'revision':
             self.setRevision(item['__revision'])
             continue
         try:
             if item['__enabled'] is False:
                 continue
         except KeyError:
             continue
         self._config.append(item)
Ejemplo n.º 13
0
def sendSelfStat(t, kwargs):
    c       = core.getCoreInstance()
    agentID = t._parent.agentID
    i       = t._parent.interfaceInstance
    cLayer  = t._parent.contractorLayer
    scheduler   = t._parent.scheduler
    c_data  = cLayer.getStat()    
    info    = {'agent': {'__id': agentID, 'state': 'started'}}
    ip      = socket.gethostbyname(socket.gethostname())
    schedulerStat   = scheduler.getScheduledTask()
    info['agent']['scheduler']  = schedulerStat
    info['agent']['ip'] = ip
    info['agent']['version'] = (c.getStat())['agent']['version']
    info['agent']['instances']  = (c.getStat())['agent']['instances']
    info['data']    = c_data
    i.post(info)
Ejemplo n.º 14
0
 def __init__(self):
     self._tagList   = []
     self._st = core.getCoreInstance().getInstance('STORAGE').getInstance()
     self._st.set_default_collection('groups')
     for item in self._st.find({}):
         self._tagList.append(item)
Ejemplo n.º 15
0
 def __init__(self):
     self._st = core.getCoreInstance().getInstance('STORAGE').getInstance()
     self._st.set_default_collection('files')
Ejemplo n.º 16
0
 def __init__(self):
     self._cmd   = []
     self._st = core.getCoreInstance().getInstance('STORAGE').getInstance()
     self._st.set_default_collection('commands')
     for item in self._st.find({'_new': True}):
         self._cmd.append(item)        
Ejemplo n.º 17
0
def updateStat(t, kwargs):
    try:
        if kwargs['core']:
            core.getCoreInstance().updateStat()            
    except KeyError:
        pass