/** * Used only from the old ui. New ui does not have the notion of "approved" agents only "enabled" ones. * * @deprecated */ public boolean canApprove() { return agentConfigStatus != AgentConfigStatus.Enabled && !agentConfig.isDisabled(); }
public boolean isEnabled() { return !isDisabled(); }
public boolean isDisabled() { return agentConfig().isDisabled(); }
public Agents findAgentsMatching(ResourceConfigs resourceConfigs) { Agents found = new Agents(); for (AgentConfig agent : agents) { if (agent.hasAllResources(resourceConfigs) && !agent.isDisabled()) { found.add(agent); } } return found; }
public void saveOrUpdateAgent(AgentInstance agentInstance, Username currentUser) { AgentConfig agentConfig = agentInstance.agentConfig(); if (goConfigService.hasAgent(agentConfig.getUuid())) { this.updateAgentApprovalStatus(agentConfig.getUuid(), agentConfig.isDisabled(), currentUser); } else { this.addAgent(agentConfig, currentUser); } }
public void syncConfig(AgentConfig agentConfig) { this.agentConfig = agentConfig; if (agentConfig.isElastic()) { agentRuntimeInfo = ElasticAgentRuntimeInfo.fromServer(agentRuntimeInfo, agentConfig.getElasticAgentId(), agentConfig.getElasticPluginId()); } if (agentRuntimeInfo.getRuntimeStatus() == AgentRuntimeStatus.Unknown) { agentRuntimeInfo.idle(); } updateConfigStatus(agentConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled); }
public static AgentInstance createFromConfig(AgentConfig agentInConfig, SystemEnvironment systemEnvironment, AgentStatusChangeListener agentStatusChangeListener) { AgentType type = agentInConfig.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE; AgentInstance result = new AgentInstance(agentInConfig, type, systemEnvironment, agentStatusChangeListener); result.agentConfigStatus = agentInConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled; result.errors.addAll(agentInConfig.errors()); for (ResourceConfig resourceConfig : agentInConfig.getResourceConfigs()) { result.errors.addAll(resourceConfig.errors()); } return result; }
@Test public void shouldDenyAgentWhenItIsNotBuilding() throws Exception { AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class)); original.update(idleRuntimeInfo()); original.deny(); assertThat(agentConfig.isDisabled(), is(true)); assertThat(original.getStatus(), is(AgentStatus.Disabled)); }
@Test public void shouldBeAbleToDenyAgentThatIsRunningCancelledJob() { AgentConfig config = new AgentConfig("UUID", "A", "127.0.0.1"); AgentInstance agent = new AgentInstance(config, LOCAL, systemEnvironment, mock(AgentStatusChangeListener.class)); agent.cancel(); AgentBuildingInfo cancelled = agent.getBuildingInfo(); assertThat(agent.canDisable(), is(true)); agent.deny(); assertThat(config.isDisabled(), is(true)); assertThat(agent.getStatus(), is(AgentStatus.Disabled)); assertThat(agent.getBuildingInfo(), is(cancelled)); }
@Test public void shouldBeAbleToDenyAgentWhenItIsBuilding() throws Exception { AgentInstance original = AgentInstance.createFromConfig(agentConfig, systemEnvironment, mock(AgentStatusChangeListener.class)); AgentRuntimeInfo runtimeInfo = buildingRuntimeInfo(); original.update(runtimeInfo); assertThat(original.canDisable(), is(true)); original.deny(); assertThat(agentConfig.isDisabled(), is(true)); assertThat(original.getStatus(), is(AgentStatus.Disabled)); assertThat(original.getBuildingInfo(), is(runtimeInfo.getBuildingInfo())); }