Пример #1
0
 async def handle_heartbeat(self, **kwargs):
     """
     Accept all components of an agent profile and save a new agent or register an updated heartbeat.
     :param kwargs: key/value pairs
     :return: the agent object, instructions to execute
     """
     results = kwargs.pop('results', [])
     for agent in await self.get_service('data_svc').locate(
             'agents', dict(paw=kwargs.get('paw', None))):
         await agent.heartbeat_modification(**kwargs)
         self.log.debug('Incoming %s beacon from %s' %
                        (agent.contact, agent.paw))
         for result in results:
             await self._save(Result(**result))
         return agent, await self._get_instructions(agent)
     agent = await self.get_service('data_svc').store(
         Agent.from_dict(
             dict(sleep_min=self.get_config(name='agents',
                                            prop='sleep_min'),
                  sleep_max=self.get_config(name='agents',
                                            prop='sleep_max'),
                  watchdog=self.get_config(name='agents', prop='watchdog'),
                  **kwargs)))
     await self._add_agent_to_operation(agent)
     self.log.debug('First time %s beacon from %s' %
                    (agent.contact, agent.paw))
     await agent.bootstrap(self.get_service('data_svc'))
     return agent, await self._get_instructions(agent)
Пример #2
0
 async def handle_heartbeat(self, **kwargs):
     results = kwargs.pop('results', [])
     for agent in await self.get_service('data_svc').locate(
             'agents', dict(paw=kwargs.get('paw', None))):
         await agent.heartbeat_modification(**kwargs)
         self.log.debug('Incoming %s beacon from %s' %
                        (agent.contact, agent.paw))
         for result in results:
             await self._save(Result(**result))
         return agent, await self._get_instructions(agent)
     agent = await self.get_service('data_svc').store(
         Agent.from_dict(
             dict(sleep_min=self.get_config(name='agents',
                                            prop='sleep_min'),
                  sleep_max=self.get_config(name='agents',
                                            prop='sleep_max'),
                  watchdog=self.get_config(name='agents', prop='watchdog'),
                  **kwargs)))
     await self._add_agent_to_operation(agent)
     self.log.debug('First time %s beacon from %s' %
                    (agent.contact, agent.paw))
     await agent.bootstrap(self.get_service('data_svc'))
     return agent, await self._get_instructions(agent)