Search in sources :

Example 41 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class AbstractUserDataUpdateAction method createFlowContext.

@Override
protected StackContext createFlowContext(FlowParameters flowParameters, StateContext<UpdateUserDataState, UpdateUserDataEvents> stateContext, P payload) {
    Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
    MDCBuilder.buildMdcContext(stack);
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformvariant()).withLocation(location).withUserName(stack.getOwner()).withAccountId(stack.getAccountId()).build();
    CloudCredential cloudCredential = credentialConverter.convert(credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn()));
    CloudStack cloudStack = cloudStackConverter.convert(stack);
    return new StackContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack);
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.freeipa.entity.Stack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 42 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class MachineUserRemoveHandler method cleanupMachineUser.

private void cleanupMachineUser(Long stackId) {
    Stack stack = stackService.getStackById(stackId);
    Telemetry telemetry = stack.getTelemetry();
    if (telemetry != null && (telemetry.isClusterLogsCollectionEnabled() || StringUtils.isNotBlank(stack.getDatabusCredential()))) {
        ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> altusMachineUserService.cleanupMachineUser(stack, telemetry));
    } else {
        LOGGER.info("Machine user cleanup is not needed.");
    }
}
Also used : Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 43 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class TerminationService method requestDeletion.

public void requestDeletion(Long stackId, List<String> instanceIds) {
    try {
        transactionService.required(() -> {
            Stack stack = stackService.getByIdWithListsInTransaction(stackId);
            requestDeletionForInstances(stack, instanceIds);
        });
    } catch (TransactionExecutionException ex) {
        LOGGER.info("Failed to request deletion for cluster infrastructure.");
        throw new TerminationFailedException(ex);
    }
}
Also used : TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) TerminationFailedException(com.sequenceiq.freeipa.flow.stack.termination.TerminationFailedException) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 44 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class TerminationService method finalizeTerminationForInstancesWithoutInstanceIds.

public void finalizeTerminationForInstancesWithoutInstanceIds(Long stackId) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    terminateInstancesWithoutInstanceIds(stack);
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack)

Example 45 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class FreeIpaScalingValidationServiceTest method testDownscaleIfInvalidInstancesExistsThenValidationFails.

@Test
public void testDownscaleIfInvalidInstancesExistsThenValidationFails() {
    Stack stack = mock(Stack.class);
    BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.validateStackForDownscale(createValidImSet(2), stack, null));
    assertEquals("Downscaling currently only available for FreeIPA installation with 3 instances", exception.getMessage());
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23