Search in sources :

Example 11 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class StackToBlueprintPreparationObjectConverter method convert.

@Override
public BlueprintPreparationObject convert(Stack source) {
    try {
        Optional<SmartSenseSubscription> aDefault = smartSenseSubscriptionService.getDefault();
        Cluster cluster = clusterService.getById(source.getCluster().getId());
        FileSystem fileSystem = cluster.getFileSystem();
        LdapConfig ldapConfig = cluster.getLdapConfig();
        StackRepoDetails hdpRepo = clusterComponentConfigProvider.getHDPRepo(cluster.getId());
        String stackRepoDetailsHdpVersion = hdpRepo != null ? hdpRepo.getHdpVersion() : null;
        Map<String, List<InstanceMetaData>> groupInstances = instanceGroupMetadataCollector.collectMetadata(source);
        HdfConfigs hdfConfigs = hdfConfigProvider.createHdfConfig(cluster.getHostGroups(), groupInstances, cluster.getBlueprint().getBlueprintText());
        BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(cluster.getBlueprint().getBlueprintText());
        FileSystemConfigurationView fileSystemConfigurationView = null;
        if (source.getCluster().getFileSystem() != null) {
            fileSystemConfigurationView = new FileSystemConfigurationView(fileSystemConfigurationProvider.fileSystemConfiguration(fileSystem, source), fileSystem == null ? false : fileSystem.isDefaultFs());
        }
        IdentityUser identityUser = userDetailsService.getDetails(cluster.getOwner(), UserFilterField.USERID);
        return BlueprintPreparationObject.Builder.builder().withFlexSubscription(source.getFlexSubscription()).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withHostgroups(hostGroupService.getByCluster(cluster.getId())).withGateway(cluster.getGateway()).withBlueprintView(new BlueprintView(cluster, blueprintStackInfo)).withStackRepoDetailsHdpVersion(stackRepoDetailsHdpVersion).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigsProvider.generalClusterConfigs(source, cluster, identityUser)).withSmartSenseSubscriptionId(aDefault.isPresent() ? aDefault.get().getSubscriptionId() : null).withLdapConfig(ldapConfig).withHdfConfigs(hdfConfigs).withKerberosConfig(cluster.isSecure() ? cluster.getKerberosConfig() : null).build();
    } catch (BlueprintProcessingException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HdfConfigs(com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) IOException(java.io.IOException) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) FileSystemConfigurationView(com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView) List(java.util.List)

Example 12 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class StackToStackResponseConverter method convertComponentConfig.

private void convertComponentConfig(StackResponse stackJson, Stack source) {
    try {
        if (source.getCluster() != null) {
            StackRepoDetails stackRepoDetails = clusterComponentConfigProvider.getHDPRepo(source.getCluster().getId());
            if (stackRepoDetails != null && stackRepoDetails.getStack() != null) {
                String repositoryVersion = stackRepoDetails.getStack().get(StackRepoDetails.REPOSITORY_VERSION);
                if (!StringUtils.isEmpty(repositoryVersion)) {
                    stackJson.setHdpVersion(repositoryVersion);
                } else {
                    stackJson.setHdpVersion(stackRepoDetails.getHdpVersion());
                }
            }
            AmbariRepo ambariRepo = clusterComponentConfigProvider.getAmbariRepo(source.getCluster().getId());
            if (ambariRepo != null) {
                stackJson.setAmbariVersion(ambariRepo.getVersion());
            }
        }
        CloudbreakDetails cloudbreakDetails = componentConfigProvider.getCloudbreakDetails(source.getId());
        if (cloudbreakDetails != null) {
            stackJson.setCloudbreakDetails(getConversionService().convert(cloudbreakDetails, CloudbreakDetailsJson.class));
        }
    } catch (RuntimeException e) {
        LOGGER.error("Failed to convert dynamic component.", e);
    }
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) CloudbreakDetailsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Example 13 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class ImageService method createHDPRepo.

private StackRepoDetails createHDPRepo(StackDetails hdpStack) {
    StackRepoDetails repo = new StackRepoDetails();
    repo.setHdpVersion(hdpStack.getVersion());
    repo.setStack(hdpStack.getRepo().getStack());
    repo.setUtil(hdpStack.getRepo().getUtil());
    return repo;
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)

Example 14 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class ImageService method getComponents.

private List<Component> getComponents(Stack stack, Map<InstanceGroupType, String> userData, com.sequenceiq.cloudbreak.cloud.model.catalog.Image imgFromCatalog, String imageName, String imageCatalogUrl, String imageCatalogName, String imageId) throws JsonProcessingException, CloudbreakImageCatalogException {
    List<Component> components = new ArrayList<>();
    Image image = new Image(imageName, userData, imgFromCatalog.getOsType(), imageCatalogUrl, imageCatalogName, imageId);
    Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    components.add(imageComponent);
    if (imgFromCatalog.getStackDetails() != null) {
        components.add(getAmbariComponent(stack, imgFromCatalog));
        StackDetails stackDetails = imgFromCatalog.getStackDetails();
        Component stackRepoComponent;
        if (!imgFromCatalog.getStackDetails().getRepo().getKnox().isEmpty()) {
            StackRepoDetails hdfRepo = createHDFRepo(stackDetails);
            stackRepoComponent = new Component(ComponentType.HDF_REPO_DETAILS, ComponentType.HDF_REPO_DETAILS.name(), new Json(hdfRepo), stack);
        } else {
            StackRepoDetails repo = createHDPRepo(stackDetails);
            stackRepoComponent = new Component(ComponentType.HDP_REPO_DETAILS, ComponentType.HDP_REPO_DETAILS.name(), new Json(repo), stack);
        }
        components.add(stackRepoComponent);
    }
    return components;
}
Also used : StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ArrayList(java.util.ArrayList) StackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.StackDetails) Json(com.sequenceiq.cloudbreak.domain.json.Json) Component(com.sequenceiq.cloudbreak.domain.Component) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 15 with StackRepoDetails

use of com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails in project cloudbreak by hortonworks.

the class ClusterCommonService method recreateCluster.

private void recreateCluster(Long stackId, UpdateClusterJson updateJson) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<HostGroup> hostGroups = new HashSet<>();
    for (HostGroupRequest json : updateJson.getHostgroups()) {
        HostGroup hostGroup = conversionService.convert(json, HostGroup.class);
        hostGroup = hostGroupDecorator.decorate(hostGroup, json, user, stackId, false, false);
        hostGroups.add(hostGroup);
    }
    AmbariStackDetailsJson stackDetails = updateJson.getAmbariStackDetails();
    StackRepoDetails stackRepoDetails = null;
    if (stackDetails != null) {
        stackRepoDetails = conversionService.convert(stackDetails, StackRepoDetails.class);
    }
    clusterService.recreate(stackId, updateJson.getBlueprintId(), hostGroups, updateJson.getValidateBlueprint(), stackRepoDetails, updateJson.getKerberosPassword(), updateJson.getKerberosPrincipal());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HashSet(java.util.HashSet)

Aggregations

StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)21 AmbariRepo (com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)7 Test (org.junit.Test)4 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)3 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)3 Json (com.sequenceiq.cloudbreak.domain.json.Json)3 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)2 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 AmbariStackDetailsResponse (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsResponse)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)1 CloudbreakDetailsJson (com.sequenceiq.cloudbreak.api.model.CloudbreakDetailsJson)1