Search in sources :

Example 46 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes.

@Test
public void testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
    instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
    ObjectNode rootNode = jsonNodeFactory.objectNode();
    ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
    addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, MA_MIN1_MAX1);
    addHostGroup(hostGroupsNode, "gateway2", SL_MIN0_MAX3, MA_MIN1_MAX3);
    addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, MA_MIN1_MAX5);
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
    Cluster cluster = new Cluster();
    cluster.setSecure(true);
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    cluster.setGateway(gateway);
    thrown.expect(BlueprintValidationException.class);
    thrown.expectMessage("In case of Knox and Kerberos each 'Ambari Server' node must include the 'KNOX_GATEWAY' service. " + "The following host groups are missing the service: gateway1,gateway2");
    // WHEN
    underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN exception thrown
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Test(org.junit.Test)

Example 47 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class BlueprintValidatorTest method testValidateBlueprintForStackShouldNotThrowAnyExceptionWhenBlueprintContainsUnknownComponent.

@Test
public void testValidateBlueprintForStackShouldNotThrowAnyExceptionWhenBlueprintContainsUnknownComponent() throws IOException {
    // GIVEN
    Blueprint blueprint = createBlueprint();
    Set<InstanceGroup> instanceGroups = createInstanceGroups();
    Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
    instanceGroups.add(createInstanceGroup("gateway", 1));
    JsonNode blueprintJsonTree = createJsonTreeWithUnknownComponent();
    BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(blueprintJsonTree);
    // WHEN
    underTest.validateBlueprintForStack(blueprint, hostGroups, instanceGroups);
// THEN doesn't throw exception
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 48 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class BlueprintController method getPublics.

@Override
public Set<BlueprintResponse> getPublics() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<Blueprint> blueprints = blueprintService.retrieveAccountBlueprints(user);
    return getBlueprintResponses(user, blueprints);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 49 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class ClusterCommonService method clusterHostgroupAdjustmentChange.

private void clusterHostgroupAdjustmentChange(Long stackId, UpdateClusterJson updateJson, Stack stack) {
    if (!stack.isAvailable()) {
        throw new BadRequestException(String.format("Stack '%s' is currently in '%s' state. PUT requests to a cluster can only be made if the underlying stack is 'AVAILABLE'.", stackId, stack.getStatus()));
    }
    LOGGER.info("Cluster host adjustment request received. Stack id: {} ", stackId);
    Blueprint blueprint = stack.getCluster().getBlueprint();
    HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stack.getCluster().getId(), updateJson.getHostGroupAdjustment().getHostGroup());
    if (hostGroup == null) {
        throw new BadRequestException(String.format("Host group '%s' not found or not member of the cluster '%s'", updateJson.getHostGroupAdjustment().getHostGroup(), stack.getName()));
    }
    blueprintValidator.validateHostGroupScalingRequest(blueprint, hostGroup, updateJson.getHostGroupAdjustment().getScalingAdjustment());
    clusterService.updateHosts(stackId, updateJson.getHostGroupAdjustment());
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Example 50 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint 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)

Aggregations

Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)71 Test (org.junit.Test)29 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)22 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)22 Stack (com.sequenceiq.cloudbreak.domain.Stack)16 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)7 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)6 List (java.util.List)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)4 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)4 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)4