use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentInstance method createFromLiveAgent.
public static AgentInstance createFromLiveAgent(AgentRuntimeInfo agentRuntimeInfo, SystemEnvironment systemEnvironment) {
AgentConfig config = agentRuntimeInfo.agent();
AgentType type = config.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE;
AgentInstance instance;
if (systemEnvironment.isAutoRegisterLocalAgentEnabled() && config.isFromLocalHost()) {
instance = new AgentInstance(config, type, systemEnvironment);
instance.agentConfigStatus = AgentConfigStatus.Enabled;
instance.agentRuntimeInfo.idle();
instance.update(agentRuntimeInfo);
return instance;
} else {
instance = new AgentInstance(config, type, systemEnvironment);
instance.update(agentRuntimeInfo);
}
return instance;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentMother method deniedAgent.
public static AgentConfig deniedAgent() {
AgentConfig agentConfig = new AgentConfig("uuid", "deniedAgent", "192.168.0.1");
agentConfig.disable();
return agentConfig;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentMother method elasticAgent.
public static AgentConfig elasticAgent() {
AgentConfig agentConfig = new AgentConfig(UUID.randomUUID().toString(), UUID.randomUUID().toString(), "127.0.0.1");
agentConfig.setElasticAgentId(UUID.randomUUID().toString());
agentConfig.setElasticPluginId(UUID.randomUUID().toString());
return agentConfig;
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentConfigServiceTest method shouldEnableAgentWhenAlreadyInTheConfig.
@Test
public void shouldEnableAgentWhenAlreadyInTheConfig() {
String agentId = DatabaseAccessHelper.AGENT_UUID;
AgentConfig agentConfig = new AgentConfig(agentId, "remote-host", "50.40.30.20");
agentConfig.disable();
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment(), null);
when(goConfigService.currentCruiseConfig()).thenReturn(mock(CruiseConfig.class));
when(goConfigService.hasAgent(agentConfig.getUuid())).thenReturn(true);
agentConfigService.enableAgents(Username.ANONYMOUS, instance);
shouldPerformCommand(new GoConfigDao.CompositeConfigCommand((UpdateConfigCommand) new AgentConfigService.UpdateAgentApprovalStatus(agentId, false)));
}
use of com.thoughtworks.go.config.AgentConfig in project gocd by gocd.
the class AgentConfigServiceTest method shouldEnableAgentWhenPending.
@Test
public void shouldEnableAgentWhenPending() {
String agentId = DatabaseAccessHelper.AGENT_UUID;
AgentConfig agentConfig = new AgentConfig(agentId, "remote-host", "50.40.30.20");
AgentRuntimeInfo agentRuntimeInfo = AgentRuntimeInfo.fromAgent(new AgentIdentifier("remote-host", "50.40.30.20", agentId), AgentRuntimeStatus.Unknown, "cookie", false);
AgentInstance instance = AgentInstance.createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment(), null);
agentConfigService.enableAgents(Username.ANONYMOUS, instance);
shouldPerformCommand(new GoConfigDao.CompositeConfigCommand(new AgentConfigService.AddAgentCommand(agentConfig)));
}
Aggregations