public String getHostname() { return agentConfig().getHostname(); }
public AgentInstance findFirstByHostname(String hostname) { for (AgentInstance agentInstance : currentInstances()) { if (agentInstance.agentConfig().getHostname().equals(hostname)) { return agentInstance; } } return new NullAgentInstance(""); }
public AgentIdentifier getAgentIdentifier() { return new AgentIdentifier(this.getHostname(), getIpAddress(), getUuid()); }
private void saveBuildAgent(JobInstance instance) { propertyDao.save(instance.getId(), new Property(CRUISE_AGENT, goConfigService.agentByUuid(instance.getAgentUuid()).getHostname())); }
public Registration assignCertification() { if (AgentConfigStatus.Pending.equals(agentConfigStatus)) { return Registration.createNullPrivateKeyEntry(); } X509CertificateGenerator certificateGenerator = new X509CertificateGenerator(); Registration entry = certificateGenerator.createAgentCertificate(new SystemEnvironment().agentkeystore(), agentConfig.getHostname()); return new Registration(entry.getPrivateKey(), entry.getChain()); }
@Test public void shouldFindAgentByUuid() { Agents agents = new Agents(); agents.add(new AgentConfig("1", "localhost", "2")); assertThat(agents.getAgentByUuid("1").getHostname(), is("localhost")); }
@Test public void shouldSupportMultipleAgentsFromSameBox() throws Exception { CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(ConfigMigrator.migrate(WITH_MULTIPLE_LOCAL_AGENT_CONFIG)).config; assertThat(cruiseConfig.agents().size(), is(2)); assertThat(cruiseConfig.agents().get(0).getHostname(), is(cruiseConfig.agents().get(1).getHostname())); assertThat(cruiseConfig.agents().get(0).getIpAddress(), is(cruiseConfig.agents().get(1).getIpAddress())); assertThat(cruiseConfig.agents().get(0).getUuid(), is(not(cruiseConfig.agents().get(1).getUuid()))); }
@Test public void shouldDenyAgentWhenAgentIsDeniedInConfigFile() throws Exception { AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class)); original.update(buildingRuntimeInfo()); AgentConfig newAgentConfig = new AgentConfig(agentConfig.getUuid(), agentConfig.getHostname(), agentConfig.getIpAddress()); newAgentConfig.disable(); original.syncConfig(newAgentConfig); assertThat(original.getStatus(), is(AgentStatus.Disabled)); }