public boolean hasAgent(String uuid) { return !getAgentByUuid(uuid).isNull(); }
public AgentConfig agentByUuid(String uuid) { return agents().getAgentByUuid(uuid); }
public Agents filter(List<String> uuids) { Agents agents = new Agents(); for (String uuid : uuids) { agents.add(getAgentByUuid(uuid)); } return agents; }
@Override public boolean isValid(CruiseConfig preprocessedConfig) { boolean isValid = true; for (String uuid : agentsUuids) { AgentConfig agentConfig = preprocessedConfig.agents().getAgentByUuid(uuid); isValid = agentConfig.validateTree(ConfigSaveValidationContext.forChain(preprocessedConfig)) && isValid; validatedAgents.add(agentConfig); } return isValid; }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent approval status; Agent [" + uuid + "] not found."); agentConfig.setDisabled(denied); return cruiseConfig; }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); agentConfig.getResourceConfigs().importFromCsv(resources); return cruiseConfig; } }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent resources; Agent [" + uuid + "] not found."); agentConfig.setResourceConfigs(resourceConfigs); return cruiseConfig; } }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent hostname; Agent [" + uuid + "] not found."); agentConfig.setHostName(hostname); return cruiseConfig; }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent ipAddress; Agent [" + uuid + "] not found."); agentConfig.setIpAddress(ipAddress); return cruiseConfig; }
public AgentConfig updateAgent(UpdateConfigCommand command, String uuid, HttpOperationResult result, Username currentUser) { AgentConfigsUpdateValidator validator = new AgentConfigsUpdateValidator(asList(uuid)); try { updateAgents(command, validator, currentUser); result.ok(String.format("Updated agent with uuid %s.", uuid)); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { result.unprocessibleEntity("Updating agent failed:", e.getMessage(), HealthStateType.general(HealthStateScope.GLOBAL)); GoConfigInvalidException goConfigInvalidException = (GoConfigInvalidException) e; return goConfigInvalidException.getCruiseConfig().agents().getAgentByUuid(uuid); } else { result.internalServerError("Updating agent failed: " + e.getMessage(), HealthStateType.general(HealthStateScope.GLOBAL)); return null; } } return goConfigService.agents().getAgentByUuid(uuid); }
public Agent findAgentObjectByUuid(String uuid) { Agent agent; AgentConfig agentFromConfig = agentConfigService.agents().getAgentByUuid(uuid); if (agentFromConfig != null && !agentFromConfig.isNull()) { agent = Agent.fromConfig(agentFromConfig); } else { agent = agentDao.agentByUuid(uuid); } return agent; }
private boolean validateDuplicateElasticAgentIds() { HashMap<String, String> elasticAgentIdToUUIDMap = new HashMap<>(); for (AgentConfig agentConfig : this) { if (!agentConfig.isElastic()) { continue; } if (elasticAgentIdToUUIDMap.containsKey(agentConfig.getElasticAgentId())) { AgentConfig duplicatedAgentConfig = this.getAgentByUuid(elasticAgentIdToUUIDMap.get(agentConfig.getElasticAgentId())); String error = String.format("Duplicate ElasticAgentId found for agents [%s, %s]", duplicatedAgentConfig.getUuid(), agentConfig.getUuid()); agentConfig.addError(elasticAgentId, error); duplicatedAgentConfig.addError("elasticAgentId", error); return false; } elasticAgentIdToUUIDMap.put(agentConfig.getElasticAgentId(), agentConfig.getUuid()); } return true; }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent resources; Agent [" + uuid + "] not found."); if (action.equals(TriStateSelection.Action.add)) { agentConfig.addResourceConfig(resourceConfig); } else if (action.equals(TriStateSelection.Action.remove)) { agentConfig.removeResource(resourceConfig); } else if (action.equals(TriStateSelection.Action.nochange)) { //do nothing } else { bomb(String.format("unsupported action '%s'", action)); } return cruiseConfig; } }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); if (agentConfig.isNull()) { bomb("Unable to delete agent; Agent [" + uuid + "] not found."); } cruiseConfig.getEnvironments().removeAgentFromAllEnvironments(uuid); cruiseConfig.agents().remove(agentConfig); return cruiseConfig; }
@Test public void shouldFindAgentByUuid() { Agents agents = new Agents(); agents.add(new AgentConfig("1", "localhost", "2")); assertThat(agents.getAgentByUuid("1").getHostname(), is("localhost")); }
public CruiseConfig update(CruiseConfig cruiseConfig) { AgentConfig agentConfig = cruiseConfig.agents().getAgentByUuid(uuid); bombIfNull(agentConfig, "Unable to set agent resources; Agent [" + uuid + "] not found."); EnvironmentConfig environmentConfig = cruiseConfig.getEnvironments().find(new CaseInsensitiveString(environmentName)); if (environmentConfig == null) { agentConfig.addError("environments", "Environment [" + environmentName + "] does not exist."); } else { if (action.equals(TriStateSelection.Action.add)) { environmentConfig.addAgentIfNew(uuid); } else if (action.equals(TriStateSelection.Action.remove)) { environmentConfig.removeAgent(uuid); } else if (action.equals(TriStateSelection.Action.nochange)) { //do nothing } else { bomb(String.format("unsupported action '%s'", action)); } } return cruiseConfig; } }