Search in sources :

Example 16 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class ClusterCreationSetupService method prepare.

public Cluster prepare(ClusterRequest request, Stack stack, Blueprint blueprint, IdentityUser user) throws Exception {
    String stackName = stack.getName();
    long start = System.currentTimeMillis();
    Cluster cluster = conversionService.convert(request, Cluster.class);
    cluster.setStack(stack);
    LOGGER.info("Cluster conversion took {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    start = System.currentTimeMillis();
    cluster = clusterDecorator.decorate(cluster, request, blueprint, user, stack);
    LOGGER.info("Cluster object decorated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    start = System.currentTimeMillis();
    List<ClusterComponent> components = new ArrayList<>();
    Set<Component> allComponent = componentConfigProvider.getAllComponentsByStackIdAndType(stack.getId(), Sets.newHashSet(ComponentType.AMBARI_REPO_DETAILS, ComponentType.HDP_REPO_DETAILS, ComponentType.IMAGE));
    Optional<Component> stackAmbariRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.AMBARI_REPO_DETAILS) && c.getName().equalsIgnoreCase(ComponentType.AMBARI_REPO_DETAILS.name())).findAny();
    Optional<Component> stackHdpRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.HDP_REPO_DETAILS) && c.getName().equalsIgnoreCase(ComponentType.HDP_REPO_DETAILS.name())).findAny();
    Optional<Component> stackImageComponent = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.IMAGE) && c.getName().equalsIgnoreCase(ComponentType.IMAGE.name())).findAny();
    ClusterComponent ambariRepoConfig = determineAmbariRepoConfig(stackAmbariRepoConfig, request.getAmbariRepoDetailsJson(), stackImageComponent, cluster);
    components.add(ambariRepoConfig);
    ClusterComponent hdpRepoConfig = determineHDPRepoConfig(blueprint, stack.getId(), stackHdpRepoConfig, request, cluster, user, stackImageComponent);
    components.add(hdpRepoConfig);
    checkVDFFile(ambariRepoConfig, hdpRepoConfig, stackName);
    LOGGER.info("Cluster components saved in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    start = System.currentTimeMillis();
    Cluster savedCluster = clusterService.create(user, stack, cluster, components);
    LOGGER.info("Cluster object creation took {} ms for stack {}", System.currentTimeMillis() - start, stackName);
    return savedCluster;
}
Also used : ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) Component(com.sequenceiq.cloudbreak.domain.Component) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) LoggerFactory(org.slf4j.LoggerFactory) FileSystemValidator(com.sequenceiq.cloudbreak.controller.validation.filesystem.FileSystemValidator) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) StringUtils(org.apache.commons.lang3.StringUtils) CUSTOM_VDF_REPO_KEY(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails.CUSTOM_VDF_REPO_KEY) JsonNode(com.fasterxml.jackson.databind.JsonNode) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) DefaultHDPInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDPInfo) VDF_REPO_KEY_PREFIX(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails.VDF_REPO_KEY_PREFIX) Set(java.util.Set) AMBARI_VERSION_2_6_0_0(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariRepositoryVersionService.AMBARI_VERSION_2_6_0_0) Sets(com.google.common.collect.Sets) List(java.util.List) AmbariRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson) DefaultHDFInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDFInfo) Entry(java.util.Map.Entry) ComponentConfigProvider(com.sequenceiq.cloudbreak.service.ComponentConfigProvider) Optional(java.util.Optional) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) SerializationUtils(org.apache.commons.lang3.SerializationUtils) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) Named(javax.inject.Named) Json(com.sequenceiq.cloudbreak.domain.json.Json) StackInfo(com.sequenceiq.cloudbreak.cloud.model.component.StackInfo) CredentialToCloudCredentialConverter(com.sequenceiq.cloudbreak.converter.spi.CredentialToCloudCredentialConverter) Stack(com.sequenceiq.cloudbreak.domain.Stack) ConversionService(org.springframework.core.convert.ConversionService) ClusterDecorator(com.sequenceiq.cloudbreak.service.decorator.ClusterDecorator) AmbariRepositoryVersionService(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariRepositoryVersionService) Logger(org.slf4j.Logger) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) DefaultHDFEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDFEntries) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) DefaultHDPEntries(com.sequenceiq.cloudbreak.cloud.model.component.DefaultHDPEntries) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) BlueprintUtils(com.sequenceiq.cloudbreak.blueprint.utils.BlueprintUtils) DefaultAmbariRepoService(com.sequenceiq.cloudbreak.service.DefaultAmbariRepoService) JsonUtil(com.sequenceiq.cloudbreak.util.JsonUtil) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) ArrayList(java.util.ArrayList) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Component(com.sequenceiq.cloudbreak.domain.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent)

Example 17 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class ClusterTemplateController method getPublic.

@Override
public ClusterTemplateResponse getPublic(String name) {
    IdentityUser user = authenticatedUserService.getCbUser();
    ClusterTemplate clusterTemplate = clusterTemplateService.getPublicClusterTemplate(name, user);
    return conversionService.convert(clusterTemplate, ClusterTemplateResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ClusterTemplate(com.sequenceiq.cloudbreak.domain.ClusterTemplate)

Example 18 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class ClusterTemplateController method getPublics.

@Override
public Set<ClusterTemplateResponse> getPublics() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<ClusterTemplate> clusterTemplates = clusterTemplateService.retrieveAccountClusterTemplates(user);
    return toJsonList(clusterTemplates);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ClusterTemplate(com.sequenceiq.cloudbreak.domain.ClusterTemplate)

Example 19 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class ClusterTemplateController method getPrivates.

@Override
public Set<ClusterTemplateResponse> getPrivates() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<ClusterTemplate> clusterTemplates = clusterTemplateService.retrievePrivateClusterTemplates(user);
    return toJsonList(clusterTemplates);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ClusterTemplate(com.sequenceiq.cloudbreak.domain.ClusterTemplate)

Example 20 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class ConstraintTemplateController method getPublic.

@Override
public ConstraintTemplateResponse getPublic(@PathVariable String name) {
    IdentityUser user = authenticatedUserService.getCbUser();
    ConstraintTemplate template = constraintTemplateService.getPublicTemplate(name, user);
    return convert(template);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ConstraintTemplate(com.sequenceiq.cloudbreak.domain.ConstraintTemplate)

Aggregations

IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)133 Test (org.junit.Test)14 Stack (com.sequenceiq.cloudbreak.domain.Stack)13 UserFilterField (com.sequenceiq.cloudbreak.common.service.user.UserFilterField)9 Async (org.springframework.scheduling.annotation.Async)9 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 Credential (com.sequenceiq.cloudbreak.domain.Credential)8 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)8 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)7 ProxyConfig (com.sequenceiq.cloudbreak.domain.ProxyConfig)7 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)6 Before (org.junit.Before)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)6 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)5 Template (com.sequenceiq.cloudbreak.domain.Template)5 ConstraintTemplate (com.sequenceiq.cloudbreak.domain.ConstraintTemplate)4 Network (com.sequenceiq.cloudbreak.domain.Network)4 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)4