Search in sources :

Example 1 with EnvironmentEndpoint

use of com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint in project cloudbreak by hortonworks.

the class EnvironmentTestDto method delete.

@Override
public void delete(TestContext testContext, SimpleEnvironmentResponse entity, EnvironmentClient client) {
    LOGGER.info("Delete resource with name: {}", entity.getName());
    EnvironmentEndpoint credentialEndpoint = client.getDefaultClient().environmentV1Endpoint();
    credentialEndpoint.deleteByName(entity.getName(), true, false);
    setName(entity.getName());
    testContext.await(this, Map.of("status", ARCHIVED));
}
Also used : EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint)

Example 2 with EnvironmentEndpoint

use of com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint in project cloudbreak by hortonworks.

the class FreeIpaUpscaleActions method updateEnvironmentStackConfigAction.

@Bean(name = "UPSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_STATE")
public Action<?, ?> updateEnvironmentStackConfigAction() {
    return new AbstractUpscaleAction<>(StackEvent.class) {

        @Inject
        private EnvironmentEndpoint environmentEndpoint;

        @Inject
        private WebApplicationExceptionMessageExtractor webApplicationExceptionMessageExtractor;

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating environment stack config");
            try {
                ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> {
                    environmentEndpoint.updateConfigsInEnvironmentByCrn(stack.getEnvironmentCrn());
                });
                sendEvent(context, UPSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
            } catch (ClientErrorException e) {
                String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
                LOGGER.error("Failed to update the stack config due to {}", errorMessage, e);
                sendEvent(context, UPSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new UpscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            } catch (Exception e) {
                LOGGER.error("Failed to update the stack config", e);
                sendEvent(context, UPSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new UpscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            }
        }
    };
}
Also used : EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) UpscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent) ClientErrorException(javax.ws.rs.ClientErrorException) Map(java.util.Map) ClientErrorException(javax.ws.rs.ClientErrorException) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Stack(com.sequenceiq.freeipa.entity.Stack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Bean(org.springframework.context.annotation.Bean)

Example 3 with EnvironmentEndpoint

use of com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method updateEnvironmentStackConfigAction.

@Bean(name = "DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_STATE")
public Action<?, ?> updateEnvironmentStackConfigAction() {
    return new AbstractDownscaleAction<>(StackEvent.class) {

        @Inject
        private EnvironmentEndpoint environmentEndpoint;

        @Inject
        private WebApplicationExceptionMessageExtractor webApplicationExceptionMessageExtractor;

        @Override
        protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating environment stack config");
            try {
                if (!isRepair(variables) || !isChainedAction(variables) || isFinalChain(variables)) {
                    ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> environmentEndpoint.updateConfigsInEnvironmentByCrn(stack.getEnvironmentCrn()));
                }
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
            } catch (ClientErrorException e) {
                String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
                LOGGER.error("Failed to update the stack config due to {}", errorMessage, e);
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            } catch (Exception e) {
                LOGGER.error("Failed to update the stack config", e);
                sendEvent(context, DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT.selector(), new DownscaleFailureEvent(stack.getId(), "Updating environment stack config", Set.of(), Map.of(), e));
            }
        }
    };
}
Also used : EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) ClientErrorException(javax.ws.rs.ClientErrorException) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) Map(java.util.Map) ClientErrorException(javax.ws.rs.ClientErrorException) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

EnvironmentEndpoint (com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint)3 WebApplicationExceptionMessageExtractor (com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)2 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)2 Map (java.util.Map)2 ClientErrorException (javax.ws.rs.ClientErrorException)2 Bean (org.springframework.context.annotation.Bean)2 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)1 UpscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleFailureEvent)1