Search in sources :

Example 71 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class RangerRazDatalakeConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source)) {
        ApiClusterTemplateService coreSettings = createTemplate();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        return hostgroupViews.stream().filter(hg -> hg.getName().toLowerCase().equals("master")).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Component(org.springframework.stereotype.Component) CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) Map(java.util.Map) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Set(java.util.Set) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Collectors(java.util.stream.Collectors) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Example 72 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class GeneratedCmTemplateService method prepareClouderaManagerTemplate.

public GeneratedCmTemplate prepareClouderaManagerTemplate(Set<String> services, String stackType, String version, String uuid) {
    CmTemplateProcessor processor = initiateTemplate();
    Set<ServiceConfig> serviceConfigs = collectServiceConfigs(services);
    Map<String, Set<String>> hostServiceMap = new HashMap<>();
    prepareCdhVersion(stackType, version, processor);
    processor.setDisplayName(prepareDisplayName(uuid));
    processor.setServices(prepareApiClusterTemplateServices(serviceConfigs, hostServiceMap));
    processor.setHostTemplates(prepareApiClusterTemplateHostTemplates(hostServiceMap));
    return new GeneratedCmTemplate(prepareTemplate(processor));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) HashMap(java.util.HashMap) GeneratedCmTemplate(com.sequenceiq.cloudbreak.cmtemplate.generator.template.domain.GeneratedCmTemplate) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Example 73 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class OpdbServiceEndpointCollectorTest method mockTemplateComponents.

private void mockTemplateComponents() {
    CmTemplateProcessor cmTemplateProcessor = mock(CmTemplateProcessor.class);
    when(cmTemplateProcessorFactory.get(any())).thenReturn(cmTemplateProcessor);
    when(cmTemplateProcessor.getAllComponents()).thenReturn(new HashSet<>(Arrays.asList(ServiceComponent.of("HBASE", "MASTER"), ServiceComponent.of("HBASE", "REGIONSERVER"), ServiceComponent.of("HBASE", "HBASERESTSERVER"), ServiceComponent.of("PHOENIX", "PHOENIX_QUERY_SERVER"), ServiceComponent.of("CLOUDERA_MANAGER", "CM-API"), ServiceComponent.of("CLOUDERA_MANAGER_UI", "CM-UI"))));
}
Also used : CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Example 74 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class ServiceEndpointCollectorTest method mockBlueprintTextProcessor.

private void mockBlueprintTextProcessor() {
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{\"Blueprints\":{}}");
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    blueprint.setWorkspace(workspace);
    when(blueprintService.getByNameForWorkspaceId(any(), anyLong())).thenReturn(blueprint);
    CmTemplateProcessor cmTemplateProcessor = mock(CmTemplateProcessor.class);
    when(cmTemplateProcessorFactory.get(any())).thenReturn(cmTemplateProcessor);
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 75 with CmTemplateProcessor

use of com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildInstanceGroups.

private List<Group> buildInstanceGroups(Stack stack, List<InstanceGroup> instanceGroups, StackAuthentication stackAuthentication, Collection<String> deleteRequests, DetailedEnvironmentResponse environment) {
    // sort by name to avoid shuffling the different instance groups
    Collections.sort(instanceGroups);
    List<Group> groups = new ArrayList<>();
    Cluster cluster = stack.getCluster();
    if (cluster != null) {
        String blueprintText = cluster.getBlueprint() != null ? cluster.getBlueprint().getBlueprintText() : cluster.getExtendedBlueprintText();
        if (blueprintText != null) {
            CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(blueprintText);
            Map<String, Set<String>> componentsByHostGroup = cmTemplateProcessor.getComponentsByHostGroup();
            Map<String, String> userDefinedTags = getUserDefinedTags(stack);
            for (InstanceGroup instanceGroup : instanceGroups) {
                if (instanceGroup.getTemplate() != null) {
                    InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stackAuthentication);
                    Optional<CloudFileSystemView> cloudFileSystemView = cloudFileSystemViewProvider.getCloudFileSystemView(cluster.getFileSystem(), componentsByHostGroup, instanceGroup);
                    groups.add(new Group(instanceGroup.getGroupName(), instanceGroup.getInstanceGroupType(), buildCloudInstances(environment, stackAuthentication, deleteRequests, instanceGroup), buildSecurity(instanceGroup), buildCloudInstanceSkeleton(environment, stackAuthentication, instanceGroup), getFields(instanceGroup), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), getRootVolumeSize(instanceGroup), cloudFileSystemView, buildDeletedCloudInstances(environment, stackAuthentication, instanceGroup), buildGroupNetwork(stack.getNetwork(), instanceGroup), userDefinedTags));
                }
            }
        }
    } else {
        LOGGER.warn("Cluster or blueprint is null for stack id:[{}] name:[{}]", stack.getId(), stack.getName());
    }
    return groups;
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Aggregations

CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)149 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)115 Test (org.junit.Test)84 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)75 List (java.util.List)46 ArrayList (java.util.ArrayList)33 Test (org.junit.jupiter.api.Test)19 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)13 HashSet (java.util.HashSet)12 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)10 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)10 Set (java.util.Set)10 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)9 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)8 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)8 Map (java.util.Map)8 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)7 Collectors (java.util.stream.Collectors)7