Search in sources :

Example 31 with Blueprint

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

the class BlueprintService method getByName.

public Blueprint getByName(String name, IdentityUser user) {
    Blueprint blueprint = blueprintRepository.findByNameInAccount(name, user.getAccount(), user.getUserId());
    if (blueprint == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found.", name));
    }
    authorizationService.hasReadPermission(blueprint);
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 32 with Blueprint

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

the class BlueprintService method get.

public Blueprint get(Long id) {
    Blueprint blueprint = blueprintRepository.findOne(id);
    if (blueprint == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found.", id));
    }
    authorizationService.hasReadPermission(blueprint);
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 33 with Blueprint

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

the class BlueprintService method delete.

public void delete(String name, IdentityUser user) {
    Blueprint blueprint = blueprintRepository.findByNameInAccount(name, user.getAccount(), user.getUserId());
    if (blueprint == null) {
        throw new NotFoundException(String.format("Blueprint '%s' not found.", name));
    }
    delete(blueprint);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 34 with Blueprint

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

the class AmbariClusterService method validateComponentsCategory.

private void validateComponentsCategory(Stack stack, String hostGroup) {
    Blueprint blueprint = stack.getCluster().getBlueprint();
    try {
        JsonNode root = JsonUtil.readTree(blueprint.getBlueprintText());
        String blueprintName = root.path("Blueprints").path("blueprint_name").asText();
        AmbariClient ambariClient = getAmbariClient(stack);
        Map<String, String> categories = ambariClient.getComponentsCategory(blueprintName, hostGroup);
        for (Entry<String, String> entry : categories.entrySet()) {
            if (entry.getValue().equalsIgnoreCase(MASTER_CATEGORY)) {
                throw new BadRequestException(String.format("Cannot downscale the '%s' hostGroupAdjustment group, because it contains a '%s' component", hostGroup, entry.getKey()));
            }
        }
    } catch (IOException e) {
        LOGGER.warn("Cannot check the host components category", e);
    }
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) AmbariClient(com.sequenceiq.ambari.client.AmbariClient)

Example 35 with Blueprint

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

the class ClusterToClusterResponseConverterTest method createSource.

@Override
public Cluster createSource() {
    Stack stack = TestUtil.stack();
    Blueprint blueprint = TestUtil.blueprint();
    Cluster cluster = TestUtil.cluster(blueprint, stack, 1L);
    ProxyConfig proxyConfig = new ProxyConfig();
    proxyConfig.setName("test");
    cluster.setProxyConfig(proxyConfig);
    stack.setCluster(cluster);
    return cluster;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) Stack(com.sequenceiq.cloudbreak.domain.Stack)

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