Search in sources :

Example 1 with StackValidationRequest

use of com.sequenceiq.cloudbreak.api.model.StackValidationRequest in project cloudbreak by hortonworks.

the class StackCreatorService method createStack.

public StackResponse createStack(IdentityUser user, StackRequest stackRequest, boolean publicInAccount) throws Exception {
    stackRequest.setAccount(user.getAccount());
    stackRequest.setOwner(user.getUserId());
    stackRequest.setOwnerEmail(user.getUsername());
    long start = System.currentTimeMillis();
    Stack stack = conversionService.convert(stackRequest, Stack.class);
    String stackName = stack.getName();
    LOGGER.info("Stack request converted to stack in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    MDCBuilder.buildMdcContext(stack);
    start = System.currentTimeMillis();
    stack = stackSensitiveDataPropagator.propagate(stackRequest.getCredentialSource(), stack, user);
    LOGGER.info("Stack propagated with sensitive data in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    start = System.currentTimeMillis();
    stack = stackDecorator.decorate(stack, stackRequest, user);
    LOGGER.info("Stack object has been decorated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    stack.setPublicInAccount(publicInAccount);
    start = System.currentTimeMillis();
    validateAccountPreferences(stack, user);
    LOGGER.info("Account preferences has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    if (stack.getOrchestrator() != null && stack.getOrchestrator().getApiEndpoint() != null) {
        stackService.validateOrchestrator(stack.getOrchestrator());
    }
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        templateValidator.validateTemplateRequest(stack.getCredential(), instanceGroup.getTemplate(), stack.getRegion(), stack.getAvailabilityZone(), stack.getPlatformVariant());
    }
    Blueprint blueprint = null;
    if (stackRequest.getClusterRequest() != null) {
        start = System.currentTimeMillis();
        StackValidationRequest stackValidationRequest = conversionService.convert(stackRequest, StackValidationRequest.class);
        LOGGER.info("Stack validation request has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
        start = System.currentTimeMillis();
        StackValidation stackValidation = conversionService.convert(stackValidationRequest, StackValidation.class);
        LOGGER.info("Stack validation object has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
        blueprint = stackValidation.getBlueprint();
        start = System.currentTimeMillis();
        stackService.validateStack(stackValidation, stackRequest.getClusterRequest().getValidateBlueprint());
        LOGGER.info("Stack has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
        CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(stack.getCredential());
        start = System.currentTimeMillis();
        fileSystemValidator.validateFileSystem(stackValidationRequest.getPlatform(), cloudCredential, stackValidationRequest.getFileSystem());
        LOGGER.info("Filesystem has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
        start = System.currentTimeMillis();
        clusterCreationService.validate(stackRequest.getClusterRequest(), cloudCredential, stack, user);
        LOGGER.info("Cluster has been validated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    }
    start = System.currentTimeMillis();
    stack = stackService.create(user, stack, stackRequest.getImageCatalog(), Optional.ofNullable(stackRequest.getImageId()), Optional.ofNullable(blueprint));
    LOGGER.info("Stack object and its dependencies has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    createClusterIfNeed(user, stackRequest, stack, stackName, blueprint);
    start = System.currentTimeMillis();
    StackResponse response = conversionService.convert(stack, StackResponse.class);
    LOGGER.info("Stack response has been created in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    start = System.currentTimeMillis();
    flowManager.triggerProvisioning(stack.getId());
    LOGGER.info("Stack provision triggered in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    return response;
}
Also used : StackValidationRequest(com.sequenceiq.cloudbreak.api.model.StackValidationRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) StackValidation(com.sequenceiq.cloudbreak.domain.StackValidation) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 2 with StackValidationRequest

use of com.sequenceiq.cloudbreak.api.model.StackValidationRequest in project cloudbreak by hortonworks.

the class StackRequestToStackValidationRequestConverter method convert.

@Override
public StackValidationRequest convert(StackRequest source) {
    ClusterRequest clusterRequest = source.getClusterRequest();
    StackValidationRequest stackValidationRequest = new StackValidationRequest();
    stackValidationRequest.setBlueprint(clusterRequest.getBlueprint());
    stackValidationRequest.setBlueprintId(clusterRequest.getBlueprintId());
    stackValidationRequest.setCredential(source.getCredential());
    stackValidationRequest.setCredentialId(source.getCredentialId());
    stackValidationRequest.setNetwork(source.getNetwork());
    stackValidationRequest.setNetworkId(source.getNetworkId());
    stackValidationRequest.setPlatform(source.getCloudPlatform());
    CredentialSourceRequest credentialSource = source.getCredentialSource();
    if (credentialSource != null) {
        if (!Strings.isNullOrEmpty(credentialSource.getSourceName())) {
            stackValidationRequest.setCredentialName(credentialSource.getSourceName());
        } else if (credentialSource.getSourceId() != null) {
            stackValidationRequest.setCredentialId(credentialSource.getSourceId());
        }
    }
    if (!Strings.isNullOrEmpty(source.getCredentialName())) {
        stackValidationRequest.setCredentialName(source.getCredentialName());
    }
    stackValidationRequest.setAccount(source.getAccount());
    stackValidationRequest.setBlueprintName(clusterRequest.getBlueprintName());
    stackValidationRequest.setFileSystem(source.getClusterRequest().getFileSystem());
    stackValidationRequest.setHostGroups(source.getClusterRequest().getHostGroups());
    stackValidationRequest.setInstanceGroups(new HashSet<>(source.getInstanceGroups()));
    return stackValidationRequest;
}
Also used : StackValidationRequest(com.sequenceiq.cloudbreak.api.model.StackValidationRequest) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) CredentialSourceRequest(com.sequenceiq.cloudbreak.api.model.CredentialSourceRequest)

Aggregations

StackValidationRequest (com.sequenceiq.cloudbreak.api.model.StackValidationRequest)2 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 CredentialSourceRequest (com.sequenceiq.cloudbreak.api.model.CredentialSourceRequest)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 StackValidation (com.sequenceiq.cloudbreak.domain.StackValidation)1