Exemplo n.º 1
0
    def save_data(self, agent_id, data):
        # registering the agent as alive
        hostname = data.get('hostname', '?')
        agent_pid = agent_id.split('-')[-1]
        self.register_agent({
            'pid': agent_pid,
            'hostname': hostname,
            'agent_id': agent_id
        })

        if agent_id in self._runs:
            data['run_id'], data['started'] = self._runs[agent_id]
        else:
            # this means we are receiving data from an agent that's
            # no longer associated with the run, so
            # we want to associate it back
            self._associate(data.get('run_id'), [agent_id])

        if data.get('data_type') == 'batch':
            for data_type, message in unbatch(data):
                message['data_type'] = data_type
                callback = functools.partial(self._db.add, message)
                self.loop.add_callback(callback)
        else:
            self._db.add(data)
Exemplo n.º 2
0
    def save_data(self, agent_id, data):
        if agent_id in self._runs:
            data['run_id'], data['started'] = self._runs[agent_id]

        if data.get('data_type') == 'batch':
            for data_type, message in unbatch(data):
                message['data_type'] = data_type
                callback = functools.partial(self._db.add, message)
                self.loop.add_callback(callback)
        else:
            self._db.add(data)
Exemplo n.º 3
0
    def save_data(self, agent_id, data):
        if agent_id in self._runs:
            data['run_id'], data['started'] = self._runs[agent_id]

        if data.get('data_type') == 'batch':
            for data_type, message in unbatch(data):
                message['data_type'] = data_type
                callback = functools.partial(self._db.add, message)
                self.loop.add_callback(callback)
        else:
            self._db.add(data)
Exemplo n.º 4
0
    def save_data(self, agent_id, data):
        # registering the agent as alive
        hostname = data.get('hostname', '?')
        agent_pid = agent_id.split('-')[-1]
        self.register_agent({'pid': agent_pid, 'hostname': hostname,
                             'agent_id': agent_id})

        if agent_id in self._runs:
            data['run_id'], data['started'] = self._runs[agent_id]
        else:
            # this means we are receiving data from an agent that's
            # no longer associated with the run, so
            # we want to associate it back
            self._associate(data.get('run_id'), [agent_id])

        if data.get('data_type') == 'batch':
            for data_type, message in unbatch(data):
                message['data_type'] = data_type
                callback = functools.partial(self._db.add, message)
                self.loop.add_callback(callback)
        else:
            self._db.add(data)
Exemplo n.º 5
0
 def batch(self, **args):
     for field, message in unbatch(args):
         if hasattr(self, field):
                 getattr(self, field)(**message)
Exemplo n.º 6
0
 def batch(self, **args):
     for field, message in unbatch(args):
         if hasattr(self, field):
             getattr(self, field)(**message)