Callback for when the bureau client acknowledges the creation of an agent.
16011
protected void agentCreated (ClientObject client, int agentId)
    {
        FoundAgent found = resolve(client, agentId, "agentCreated");
        if (found == null) {
            return;
        }

        log.info("Agent creation confirmed", "agent", found.agent.which());

        if (found.state == AgentState.STARTED) {
            found.bureau.agentStates.put(found.agent, AgentState.RUNNING);
            found.agent.setClientOid(client.getOid());

        } else if (found.state == AgentState.STILL_BORN) {
            // TODO: have a timeout for this in case the client is misbehaving or hung
            BureauSender.destroyAgent(found.bureau.clientObj, agentId);
            found.bureau.agentStates.put(found.agent, AgentState.DESTROYED);

        } else if (found.state == AgentState.PENDING ||
            found.state == AgentState.RUNNING ||
            found.state == AgentState.DESTROYED) {
            log.warning("Ignoring confirmation of creation of an agent in an unexpected state",
                        "state", found.state, "agent", found.agent.which());
        }

        found.bureau.summarize();
    }
581892
function Channel_addAgent(agent) {
  DEBUG("channel.addAgent(" + utils.JS(agent.info) + ")")
  this.agents.set(agent.info.id, agent)
  this.session.sendEvent("agentCreated", "server", agent.info)
}
1339009
protected void bureauInitialized (ClientObject client, String bureauId)
    {
        final Bureau bureau = _bureaus.get(bureauId);
        if (bureau == null) {
            log.warning("Initialization of non-existent bureau", "bureauId", bureauId);
            return;
        }

        bureau.clientObj = client;

        log.info("Bureau created, launching pending agents", "bureau", bureau);

        // find all pending agents
        Set<AgentObject> pending = Sets.newHashSet();

        for (Map.Entry<AgentObject, AgentState> entry :
            bureau.agentStates.entrySet()) {

            if (entry.getValue() == AgentState.PENDING) {
                pending.add(entry.getKey());
            }
        }

        // create them
        for (AgentObject agent : pending) {
            log.info("Creating agent", "agent", agent.which());
            BureauSender.createAgent(bureau.clientObj, agent.getOid());
            bureau.agentStates.put(agent, AgentState.STARTED);
        }

        bureau.summarize();
    }
224366
def show_agent(self, agent, **_params):
        """"""
        return self.get(self.agent_path % (agent), params=_params)
540073
public void registerShanksAgent(ShanksAgent agent)
            throws ShanksException {
        if (!this.agents.containsKey(agent.getID())) {
            this.agents.put(agent.getID(), agent);
        } else {
            throw new DuplicatedAgentIDException(agent.getID());
        }
    }
866889
async def handle_agent_message(self, agent_addr, message):
        """"""
        message_handlers = {
            AgentHello: self.handle_agent_hello,
            AgentJobStarted: self.handle_agent_job_started,
            AgentJobDone: self.handle_agent_job_done,
            AgentJobSSHDebug: self.handle_agent_job_ssh_debug,
            Pong: self._handle_pong
        }
        try:
            func = message_handlers[message.__class__]
        except:
            raise TypeError("Unknown message type %s" % message.__class__)
        self._create_safe_task(func(agent_addr, message))
1032500
async def handle_agent_hello(self, agent_addr, message: AgentHello):
        
        self._logger.info("Agent %s (%s) said hello", agent_addr, message.friendly_name)

        if agent_addr in self._registered_agents:
            # Delete previous instance of this agent, if any
            await self._delete_agent(agent_addr)

        self._registered_agents[agent_addr] = message.friendly_name
        self._available_agents.extend([agent_addr for _ in range(0, message.available_job_slots)])
        self._containers_on_agent[agent_addr] = message.available_containers.keys()
        self._ping_count[agent_addr] = 0

        # update information about available containers
        for container_name, container_info in message.available_containers.items():
            if container_name in self._containers:
                # check if the id is the same
                if self._containers[container_name][0] == container_info["id"]:
                    # ok, just add the agent to the list of agents that have the container
                    self._logger.debug("Registering container %s for agent %s", container_name, str(agent_addr))
                    self._containers[container_name][2].append(agent_addr)
                elif self._containers[container_name][1] > container_info["created"]:
                    # containers stored have been created after the new one
                    # add the agent, but emit a warning
                    self._logger.warning("Container %s has multiple version: \n"
                                         "\t Currently registered agents have version %s (%i)\n"
                                         "\t New agent %s has version %s (%i)",
                                         container_name,
                                         self._containers[container_name][0], self._containers[container_name][1],
                                         str(agent_addr), container_info["id"], container_info["created"])
                    self._containers[container_name][2].append(agent_addr)
                else:  # self._containers[container_name][1] < container_info["created"]:
                    # containers stored have been created before the new one
                    # add the agent, update the infos, and emit a warning
                    self._logger.warning("Container %s has multiple version: \n"
                                         "\t Currently registered agents have version %s (%i)\n"
                                         "\t New agent %s has version %s (%i)",
                                         container_name,
                                         self._containers[container_name][0], self._containers[container_name][1],
                                         str(agent_addr), container_info["id"], container_info["created"])
                    self._containers[container_name] = (container_info["id"], container_info["created"],
                                                        self._containers[container_name][2] + [agent_addr])
            else:
                # just add it
                self._logger.debug("Registering container %s for agent %s", container_name, str(agent_addr))
                self._containers[container_name] = (container_info["id"], container_info["created"], [agent_addr])

        # update the queue
        await self.update_queue()

        # update clients
        await self.send_container_update_to_client(self._registered_clients)
32654
@Override
    public void createAgent(String agent_name, String path) {
        logger.fine("Creating agent " + agent_name + " in Main Container");
        Object reference = new Object();
        Object empty[] = new Object[1];
        empty[0] = reference;
        try {
            AgentController agentController = mainContainer.createNewAgent(
                    agent_name, path, empty);
            this.createdAgents.put(agent_name, agentController);
            agentController.start();
            logger.fine("Agent " + agent_name
                    + " created and started in Main Container");
            try {
                Thread.sleep(MILLIS_TO_WAIT_FOR_AGENT_STARTING);
            } catch (InterruptedException e) {
                logger.warning("It was not possible to wait for agent starting... Maybe, the agent is not completely started yet.");
            }
        } catch (StaleProxyException e) {
            logger.warning("Exception creating or starting agent in MainContainer... "
                    + e);
        }
        // Register the agent
    }
942817
void handleAgentCalledEvent(AgentCalledEvent event)
    {
        AsteriskAgentImpl agent = getAgentByAgentId(event.getAgentCalled());
        if (agent == null)
        {
            logger.error("Ignored AgentCalledEvent for unknown agent " + event.getAgentCalled());
            return;
        }
        updateRingingAgents(event.getChannelCalling(), agent);
        updateAgentState(agent, AgentState.AGENT_RINGING);
    }
879985
def _on_grant(self, grant):
        '''
        
        '''
        self.set_timeout(grant.expiration_time, ContractState.expired,
                         self._run_and_terminate, self.contractor.cancelled,
                         grant)

        self.grant = grant
        # this is necessary for nested contracts to work with handing
        # the messages over
        self.set_remote_id(grant.sender_id)
        self.update_manager_address(grant.reply_to)

        self.call_agent_side(self.contractor.granted, grant,
                             ensure_state=ContractState.granted)
1083321
function sessionCreated(err, session) {
  if (err) throw err

  console.log("session created, getting remote agents")

  // add an event handler when a new agent is created in the session
  // event handler will perform an "echo" request
  session.on("ragentCreated", agentCreated)

  // get all of the current agents known
  session.getRemoteAgents(gotRemoteAgents)
}
926463
void handleAgentsEvent(AgentsEvent event)
    {
        AsteriskAgentImpl agent = new AsteriskAgentImpl(server,
                event.getName(), "Agent/" + event.getAgent(), AgentState.valueOf(event.getStatus()));
        logger.info("Adding agent " + agent.getName() + "(" + agent.getAgentId() + ")");

        addAgent(agent);
    }
614903
def initial_export(agent_id, force):
    """"""
    agent = LiveSyncAgent.find_first(id=agent_id)
    if agent is None:
        print 'No such agent'
        return
    if agent.backend is None:
        print cformat('Cannot run agent %{red!}{}%{reset} (backend not found)').format(agent.name)
        return
    print cformat('Selected agent: %{white!}{}%{reset} ({})').format(agent.name, agent.backend.title)
    if agent.initial_data_exported and not force:
        print 'The initial export has already been performed for this agent.'
        print cformat('To re-run it, use %{yellow!}--force%{reset}')
        return

    agent.create_backend().run_initial_export(Event.find(is_deleted=False))
    agent.initial_data_exported = True
    db.session.commit()
1106573
def onSendCommand(self):
        ''''''
        self.agent_host.sendCommand(self.command_entry.get())
        self.command_entry.delete(0,END)
        self.canvas.focus_set()
1268997
function(self, id) {
  let msg = {action: 'record', id: id};
  self.service.agent.notify(Constants.KEYWORDS.MASTER_WATCHER, msg);
}
101016
function sessionCreated(err, session) {
  var agentInfo = {name: ping + "er", title: "a " + ping + "er" }

  session.createAgent(agentInfo, function(err, agent) {
    console.log(ping + " agent created")
    Agent = agent
  })

  session.on("ragentCreated", function(ragent) {
    ragentCreated(ragent, "created")
  })

  session.getRemoteAgents(function(err, ragents){
    ragents.forEach(function(ragent) {
      ragentCreated(ragent, "existed")
    })
  })
}
361425
def call_agent_side(self, method, *args, **kwargs):
        '''
        
        '''
        assert not self._finalize_called, ("Attempt to call agent side code "
                                           "after finalize() method has been "
                                           "called. Method: %r" % (method, ))

        ensure_state = kwargs.pop('ensure_state', None)


        d = defer.Deferred(canceller=self._cancel_agent_side_call)
        self._agent_jobs.append(d)
        if ensure_state:
            # call method only if state check is checks in
            d.addCallback(
                lambda _: (self._ensure_state(ensure_state) and
                           method(*args, **kwargs)))
        else:
            d.addCallback(defer.drop_param, method, *args, **kwargs)
        d.addErrback(self._error_handler, method)
        d.addBoth(defer.bridge_param, self._remove_agent_job, d)
        time.call_next(d.callback, None)
        return d