/** * Approve/Unapprove the agent on given ip. * * @param ip ip * @param approve true/false */ @CacheEvict(allEntries = true, value = "agents") public void approve(String ip, boolean approve) { List<AgentInfo> found = agentRepository.findAllByIp(ip); for (AgentInfo each : found) { each.setApproved(approve); agentRepository.save(each); agentRepository.findOne(each.getId()); if (approve) { LOGGER.info("agent {} is approved", ip); } else { LOGGER.info("agent {} is not approved", ip); } } }
/** * Get a agent on given id. * * @param id agent id * @return agent */ public AgentInfo getAgent(long id) { AgentInfo agentInfo = agentRepository.findOne(id); if (agentInfo == null) { return null; } AgentControllerIdentityImplementation agentIdentity = agentManager.getAgentIdentityByIp(agentInfo.getIp()); if (agentIdentity != null) { agentInfo.setStatus(agentManager.getAgentState(agentIdentity)); agentInfo.setPort(agentManager.getAgentConnectingPort(agentIdentity)); agentInfo.setHostName(agentIdentity.getName()); agentInfo.setRegion(agentIdentity.getRegion()); agentInfo.setAgentIdentity(agentIdentity); } return agentInfo; }