Search in sources :

Example 6 with SimpleEnvironmentResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.

the class EnvDeleteActions method finishedAction.

@Bean(name = "ENV_DELETE_FINISHED_STATE")
public Action<?, ?> finishedAction() {
    return new AbstractEnvDeleteAction<>(ResourceCrnPayload.class) {

        @Override
        protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
            environmentService.findEnvironmentById(payload.getResourceId()).ifPresentOrElse(env -> {
                String originalName = env.getName();
                env.setName(generateArchiveName(env.getName()));
                env.setDeletionTimestamp(new Date().getTime());
                env.setStatus(EnvironmentStatus.ARCHIVED);
                env.setStatusReason(null);
                env.setArchived(true);
                env.setProxyConfig(null);
                Environment result = environmentService.save(env);
                EnvironmentDto environmentDto = environmentService.getEnvironmentDto(result);
                SimpleEnvironmentResponse simpleResponse = environmentResponseConverter.dtoToSimpleResponse(environmentDto, true, true);
                simpleResponse.setName(originalName);
                metricService.incrementMetricCounter(MetricType.ENV_DELETION_FINISHED, environmentDto);
                eventService.sendEventAndNotificationWithPayload(environmentDto, context.getFlowTriggerUserCrn(), ResourceEvent.ENVIRONMENT_DELETION_FINISHED, simpleResponse);
            }, () -> LOGGER.error("Cannot finish the delete flow because the environment does not exist: {}. " + "But the flow will continue, how can this happen?", payload.getResourceId()));
            LOGGER.info("Flow entered into ENV_DELETE_FINISHED_STATE");
            sendEvent(context, FINALIZE_ENV_DELETE_EVENT.event(), payload);
        }
    };
}
Also used : SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceCrnPayload(com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload) Environment(com.sequenceiq.environment.environment.domain.Environment) Map(java.util.Map) Date(java.util.Date) Bean(org.springframework.context.annotation.Bean)

Example 7 with SimpleEnvironmentResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.

the class EventSenderService method sendEventAndNotification.

public void sendEventAndNotification(EnvironmentDto environmentDto, String userCrn, ResourceEvent resourceEvent, Collection<?> messageArgs) {
    SimpleEnvironmentResponse simpleResponse = environmentResponseConverter.dtoToSimpleResponse(environmentDto, true, true);
    sendEventAndNotificationWithPayload(environmentDto, userCrn, resourceEvent, simpleResponse, messageArgs);
}
Also used : SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)

Example 8 with SimpleEnvironmentResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.

the class EnvironmentDeleteByNameAction method environmentAction.

@Override
protected EnvironmentTestDto environmentAction(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient client) throws Exception {
    SimpleEnvironmentResponse delete = client.getDefaultClient().environmentV1Endpoint().deleteByName(testDto.getName(), cascading, false);
    testDto.setResponseSimpleEnv(delete);
    Log.whenJson("Environment delete response: ", delete);
    return testDto;
}
Also used : SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)

Example 9 with SimpleEnvironmentResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.

the class EnvironmentCascadingDeleteAction method action.

@Override
public EnvironmentTestDto action(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient environmentClient) throws Exception {
    Log.when(LOGGER, "Environment cascading delete request, crn: " + testDto.getResponse().getCrn());
    SimpleEnvironmentResponse delete = environmentClient.getDefaultClient().environmentV1Endpoint().deleteByCrn(testDto.getResponse().getCrn(), true, false);
    testDto.setResponseSimpleEnv(delete);
    Log.whenJson(LOGGER, " Environment cascading delete response: ", delete);
    return testDto;
}
Also used : SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)

Aggregations

SimpleEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)8 CredentialViewResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse)3 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)2 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 ClusterTemplateV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response)1 ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1 CompactViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 ResourceCrnPayload (com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload)1 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)1 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)1 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)1 EnvironmentEndpoint (com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint)1 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)1 SimpleEnvironmentResponses (com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponses)1 ProxyViewResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyViewResponse)1