Search in sources :

Example 46 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StackCreationService method startProvisioning.

public void startProvisioning(StackContext context, Map<Object, Object> variables) {
    Stack stack = context.getStack();
    if (variables.containsKey(IMAGE_COPY_START_MILLIS)) {
        long startMillis = (long) variables.get(IMAGE_COPY_START_MILLIS);
        metricService.recordImageCopyTime(stack, startMillis);
    }
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.CREATING_INFRASTRUCTURE, "Creating infrastructure");
    flowMessageService.fireEventAndLog(stack.getId(), CREATE_IN_PROGRESS.name(), STACK_PROVISIONING);
    instanceMetaDataService.saveInstanceRequests(stack, context.getCloudStack().getGroups());
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 47 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StackCreationService method saveTlsInfo.

public Stack saveTlsInfo(StackContext context, TlsInfo tlsInfo) {
    boolean usePrivateIpToTls = tlsInfo.usePrivateIpToTls();
    Stack stack = context.getStack();
    if (usePrivateIpToTls) {
        SecurityConfig securityConfig = stack.getSecurityConfig();
        securityConfig.setUsePrivateIpToTls(true);
        stackUpdater.updateStackSecurityConfig(stack, securityConfig);
        stack = stackService.getByIdWithListsInTransaction(stack.getId());
        stack.setResources(new HashSet<>(resourceService.getAllByStackId(stack.getId())));
        LOGGER.debug("Update Stack and it's SecurityConfig to use private ip when TLS is built.");
    }
    return stack;
}
Also used : SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 48 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StackCreationService method handleFailure.

private void handleFailure(StackView stackView, String errorReason) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackView.getId());
    handleFailure(stack, errorReason);
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 49 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StackCreationService method loadBalancerProvisioningFinished.

public Stack loadBalancerProvisioningFinished(StackContext context, LaunchLoadBalancerResult result, Map<Object, Object> variables) {
    Stack stack = context.getStack();
    validateResourceResults(context.getCloudContext(), result);
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.METADATA_COLLECTION, "Metadata collection");
    Stack provisionedStack = stackService.getByIdWithListsInTransaction(stack.getId());
    provisionedStack.setResources(new HashSet<>(resourceService.getAllByStackId(stack.getId())));
    return provisionedStack;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 50 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StackCreationService method setInstanceStoreCount.

public void setInstanceStoreCount(StackContext stackContext) {
    Stack stack = stackContext.getStack();
    CloudConnector<Object> connector = cloudPlatformConnectors.get(stackContext.getCloudContext().getPlatformVariant());
    AuthenticatedContext ac = connector.authentication().authenticate(stackContext.getCloudContext(), stackContext.getCloudCredential());
    List<String> instanceTypes = stack.getInstanceGroups().stream().map(InstanceGroup::getTemplate).filter(Objects::nonNull).map(Template::getInstanceType).filter(Objects::nonNull).collect(Collectors.toList());
    InstanceStoreMetadata instanceStoreMetadata = connector.metadata().collectInstanceStorageCount(ac, instanceTypes);
    for (InstanceGroup ig : stack.getInstanceGroups()) {
        Template template = ig.getTemplate();
        if (template != null) {
            Integer instanceStorageCount = instanceStoreMetadata.mapInstanceTypeToInstanceStoreCountNullHandled(template.getInstanceType());
            if (ephemeralVolumeChecker.instanceGroupContainsOnlyDatabaseAndEphemeralVolumes(ig)) {
                LOGGER.debug("Instance storage was already requested. Setting temporary storage in template to: {}. " + "Group name: {}, Template id: {}, instance type: {}", TemporaryStorage.EPHEMERAL_VOLUMES_ONLY.name(), ig.getGroupName(), template.getId(), template.getInstanceType());
                template.setTemporaryStorage(TemporaryStorage.EPHEMERAL_VOLUMES_ONLY);
            } else if (instanceStorageCount > 0 && stack.getType().equals(StackType.WORKLOAD)) {
                LOGGER.debug("The host group's instance type has ephemeral volumes. Setting temporary storage in template to: {}. " + "Group name: {}, Template id: {}, instance type: {}", TemporaryStorage.EPHEMERAL_VOLUMES.name(), ig.getGroupName(), template.getId(), template.getInstanceType());
                template.setTemporaryStorage(TemporaryStorage.EPHEMERAL_VOLUMES);
            }
            LOGGER.debug("Setting instance storage count in template. " + "Group name: {}, Template id: {}, instance type: {}", ig.getGroupName(), template.getId(), template.getInstanceType());
            template.setInstanceStorageCount(instanceStorageCount);
            templateService.savePure(template);
        }
    }
}
Also used : InstanceStoreMetadata(com.sequenceiq.cloudbreak.cloud.model.InstanceStoreMetadata) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1041 Test (org.junit.jupiter.api.Test)326 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)255 Test (org.junit.Test)208 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)158 Map (java.util.Map)114 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)113 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)112 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)111 List (java.util.List)101 Set (java.util.Set)101 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)100 Collectors (java.util.stream.Collectors)84 Optional (java.util.Optional)83 HashSet (java.util.HashSet)82 Inject (javax.inject.Inject)80 Logger (org.slf4j.Logger)78 LoggerFactory (org.slf4j.LoggerFactory)78 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)69 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)67