Search in sources :

Example 16 with StackType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.

the class DefaultBlueprintCache method loadBlueprintsFromFile.

@PostConstruct
public void loadBlueprintsFromFile() {
    Map<String, Set<String>> blueprints = blueprints();
    for (Map.Entry<String, Set<String>> blueprintEntry : blueprints.entrySet()) {
        try {
            for (String blueprintText : blueprintEntry.getValue()) {
                String[] split = blueprintText.trim().split("=");
                if (blueprintUtils.isBlueprintNamePreConfigured(blueprintText, split)) {
                    LOGGER.debug("Load default validation '{}'.", AnonymizerUtil.anonymize(blueprintText));
                    BlueprintV4Request blueprintJson = new BlueprintV4Request();
                    blueprintJson.setName(split[0].trim());
                    JsonNode jsonNode = blueprintUtils.convertStringToJsonNode(blueprintUtils.readDefaultBlueprintFromFile(blueprintEntry.getKey(), split));
                    JsonNode blueprintNode = jsonNode.get("blueprint");
                    blueprintJson.setBlueprint(blueprintNode.toString());
                    Blueprint bp = converter.convert(blueprintJson);
                    JsonNode tags = jsonNode.get("tags");
                    Map<String, Object> tagParameters = blueprintUtils.prepareTags(tags);
                    bp.setTags(new Json(tagParameters));
                    JsonNode description = jsonNode.get("description");
                    bp.setDescription(description == null ? split[0] : description.asText(split[0]));
                    JsonNode blueprintUpgradeOption = blueprintNode.isMissingNode() ? null : blueprintNode.get("blueprintUpgradeOption");
                    bp.setBlueprintUpgradeOption(getBlueprintUpgradeOption(blueprintUpgradeOption));
                    BlueprintFile bpf = new BlueprintFile.Builder().name(bp.getName()).blueprintText(bp.getBlueprintText()).stackName(bp.getStackName()).stackVersion(bp.getStackVersion()).stackType(bp.getStackType()).blueprintUpgradeOption(bp.getBlueprintUpgradeOption()).hostGroupCount(bp.getHostGroupCount()).description(bp.getDescription()).build();
                    defaultBlueprints.put(bp.getName(), bpf);
                }
            }
        } catch (IOException e) {
            LOGGER.error("Can not read default validation from file: ", e);
        }
    }
}
Also used : Set(java.util.Set) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) JsonNode(com.fasterxml.jackson.databind.JsonNode) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) BlueprintV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request) BlueprintFile(com.sequenceiq.cloudbreak.domain.BlueprintFile) HashMap(java.util.HashMap) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct)

Example 17 with StackType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.

the class StackCreatorServiceTest method testDetermineStackTypeBasedOnTheUsedApiShouldReturnWhenStackTypeIsNullAndNotDistroXRequest.

@Test
public void testDetermineStackTypeBasedOnTheUsedApiShouldReturnWhenStackTypeIsNullAndNotDistroXRequest() {
    Stack stack = new Stack();
    stack.setType(null);
    StackType actual = underTest.determineStackTypeBasedOnTheUsedApi(stack, false);
    assertEquals(StackType.LEGACY, actual);
}
Also used : StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with StackType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType in project cloudbreak by hortonworks.

the class StackService method getByCrnInWorkspaceWithEntries.

public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
    try {
        return transactionService.required(() -> {
            Workspace workspace = workspaceService.get(workspaceId, user);
            ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
            Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
            if (stack.isEmpty()) {
                throw new NotFoundException(format("Stack not found by crn '%s'", crn));
            }
            StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
            stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
            return stackResponse;
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : ShowTerminatedClustersAfterConfig(com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Aggregations

StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)9 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)4 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)4 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)3 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)3 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)3 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 AutoscaleStackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 AutoscaleStack (com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack)2 ShowTerminatedClustersAfterConfig (com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig)2 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1 ApiException (com.cloudera.api.swagger.client.ApiException)1