Search in sources :

Example 1 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvironmentSyncServiceTest method testGetStatusByFreeipa.

@ParameterizedTest(name = "{0}")
@MethodSource("getStatusByFreeipaParams")
void testGetStatusByFreeipa(String testName, DescribeFreeIpaResponse freeIpaResponse, EnvironmentStatus expected) {
    Environment environment = new Environment();
    environment.setAccountId("cloudera");
    environment.setResourceCrn("crn");
    when(freeIpaService.internalDescribe(environment.getResourceCrn(), "cloudera")).thenReturn(Optional.of(freeIpaResponse));
    EnvironmentStatus actual = underTest.getStatusByFreeipa(environment);
    Assertions.assertEquals(expected, actual);
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Environment(com.sequenceiq.environment.environment.domain.Environment) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvironmentSyncServiceTest method testGetStatusByFreeipaWhenFreeipaAttachedButNotFound.

@Test
void testGetStatusByFreeipaWhenFreeipaAttachedButNotFound() {
    Environment environment = new Environment();
    environment.setResourceCrn("crn");
    environment.setCreateFreeIpa(true);
    when(freeIpaService.internalDescribe(environment.getResourceCrn(), "cloudera")).thenReturn(Optional.empty());
    EnvironmentStatus actual = underTest.getStatusByFreeipa(environment);
    Assertions.assertEquals(EnvironmentStatus.FREEIPA_DELETED_ON_PROVIDER_SIDE, actual);
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvironmentStructuredFlowEventFactory method getReason.

private String getReason(Environment environment) {
    EnvironmentStatus status = environment.getStatus();
    String reason = environment.getStatusReason();
    if (StringUtils.isEmpty(reason)) {
        reason = status.getResponseStatus().getDescription();
    }
    return reason;
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus)

Example 4 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvStopActions method stopDatalake.

@Bean(name = "STOP_DATALAKE_STATE")
public Action<?, ?> stopDatalake() {
    return new AbstractEnvStopAction<>(EnvStopEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvStopEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.STOP_DATALAKE_STARTED;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_STOP_DATALAKE_STARTED;
            EnvStopState envStopState = EnvStopState.STOP_DATALAKE_STATE;
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStopState);
            sendEvent(context, EnvStopHandlerSelectors.STOP_DATALAKE_HANDLER_EVENT.selector(), envDto);
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvStopEvent(com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 5 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvStartActions method startFreeipa.

@Bean(name = "START_FREEIPA_STATE")
public Action<?, ?> startFreeipa() {
    return new AbstractEnvStartAction<>(EnvStartEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.START_FREEIPA_STARTED;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_FREEIPA_STARTED;
            EnvStartState envStartState = EnvStartState.START_FREEIPA_STATE;
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
            EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
            sendEvent(context, EnvStartHandlerSelectors.START_FREEIPA_HANDLER_EVENT.selector(), environmentStartDto);
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvStartEvent(com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) EnvironmentStartDto(com.sequenceiq.environment.environment.dto.EnvironmentStartDto) Bean(org.springframework.context.annotation.Bean)

Aggregations

EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)16 CommonContext (com.sequenceiq.flow.core.CommonContext)12 Map (java.util.Map)12 Bean (org.springframework.context.annotation.Bean)12 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)11 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)10 EnvironmentStartDto (com.sequenceiq.environment.environment.dto.EnvironmentStartDto)4 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)2 EnvironmentLoadBalancerDto (com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto)2 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)2 LoadBalancerUpdateEvent (com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent)2 Test (org.junit.jupiter.api.Test)2 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1