Search in sources :

Example 26 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProvider method createBaseKnoxService.

private ApiClusterTemplateService createBaseKnoxService() {
    ApiClusterTemplateService knox = new ApiClusterTemplateService().serviceType(KnoxRoles.KNOX).refName(KNOX_SERVICE_REF_NAME);
    ApiClusterTemplateRoleConfigGroup knoxGateway = new ApiClusterTemplateRoleConfigGroup().roleType(KnoxRoles.KNOX_GATEWAY).base(true).refName(KNOX_GATEWAY_REF_NAME);
    knox.roleConfigGroups(List.of(knoxGateway));
    return knox;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Example 27 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class AbstractRoleConfigProvider method getRoleConfigs.

@Override
public Map<String, List<ApiClusterTemplateConfig>> getRoleConfigs(CmTemplateProcessor cmTemplate, TemplatePreparationObject source) {
    Optional<ApiClusterTemplateService> service = cmTemplate.getServiceByType(getServiceType());
    if (service.isEmpty()) {
        return Map.of();
    }
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    for (ApiClusterTemplateRoleConfigGroup rcg : ofNullable(service.get().getRoleConfigGroups()).orElse(new ArrayList<>())) {
        String roleType = rcg.getRoleType();
        if (roleType != null && getRoleTypes().contains(roleType)) {
            configs.put(rcg.getRefName(), getRoleConfigs(roleType, source));
        }
    }
    return configs;
}
Also used : HashMap(java.util.HashMap) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArrayList(java.util.ArrayList) List(java.util.List)

Example 28 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class CoreConfigProvider method createBaseCoreSettingsService.

private ApiClusterTemplateService createBaseCoreSettingsService() {
    ApiClusterTemplateService coreSettings = new ApiClusterTemplateService().serviceType(CORE_SETTINGS).refName(CORE_SETTINGS_SERVICE_REF_NAME);
    ApiClusterTemplateRoleConfigGroup coreSettingsRole = new ApiClusterTemplateRoleConfigGroup().roleType(STORAGEOPERATIONS).base(true).refName(CORE_SETTINGS_REF_NAME);
    coreSettings.roleConfigGroups(List.of(coreSettingsRole));
    return coreSettings;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Example 29 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class StackResponseUtils method getRoleConfigNameForHostGroup.

public String getRoleConfigNameForHostGroup(StackV4Response stackResponse, String hostGroupName, String serviceType, String roleType) throws Exception {
    String template = stackResponse.getCluster().getBlueprint().getBlueprint();
    ApiClusterTemplate cmTemplate = JsonUtil.readValue(template, ApiClusterTemplate.class);
    Set<String> hostGroupRoleConfigNames = cmTemplate.getHostTemplates().stream().filter(clusterTemplate -> clusterTemplate.getRefName().equalsIgnoreCase(hostGroupName)).findFirst().map(ApiClusterTemplateHostTemplate::getRoleConfigGroupsRefNames).orElse(List.of()).stream().collect(Collectors.toSet());
    String roleReferenceName = cmTemplate.getServices().stream().filter(s -> s.getServiceType().equalsIgnoreCase(serviceType)).findFirst().map(ApiClusterTemplateService::getRoleConfigGroups).orElse(List.of()).stream().filter(rcg -> rcg.getRoleType().equalsIgnoreCase(roleType)).filter(rcg -> hostGroupRoleConfigNames.contains(rcg.getRefName())).map(ApiClusterTemplateRoleConfigGroup::getRefName).findFirst().orElseThrow(() -> new Exception(String.format("Unable to retrieve RoleConfigGroupRefName for Service '%s', RoleType '%s'," + " HostGroup '%s', Cluster '%s'", serviceType, roleType, hostGroupName, stackResponse.getCrn())));
    return roleReferenceName;
}
Also used : ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) InstanceMetadataType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) Collectors(java.util.stream.Collectors) InstanceMetaDataV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response) List(java.util.List) Service(org.springframework.stereotype.Service) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) Optional(java.util.Optional) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate)

Example 30 with ApiClusterTemplateService

use of com.cloudera.api.swagger.model.ApiClusterTemplateService in project cloudbreak by hortonworks.

the class RangerRazDatahubConfigProviderTest method getAdditionalServicesWhenRazIsEnabledWithCm710.

@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatformDataProvider")
@DisplayName("CM 7.1.0 DH is used and Raz is requested, no additional service needs to be added to the template")
void getAdditionalServicesWhenRazIsEnabledWithCm710(String testCaseName, CloudPlatform cloudPlatform) {
    ClouderaManagerRepo cmRepo = new ClouderaManagerRepo();
    cmRepo.setVersion("7.1.0");
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    HostgroupView master = new HostgroupView("master", 0, InstanceGroupType.GATEWAY, List.of());
    HostgroupView worker = new HostgroupView("worker", 0, InstanceGroupType.CORE, List.of());
    TemplatePreparationObject preparationObject = Builder.builder().withStackType(StackType.WORKLOAD).withCloudPlatform(cloudPlatform).withProductDetails(cmRepo, List.of()).withDataLakeView(new DatalakeView(true)).withGeneralClusterConfigs(generalClusterConfigs).withHostgroupViews(Set.of(master, worker)).build();
    Map<String, ApiClusterTemplateService> additionalServices = configProvider.getAdditionalServices(cmTemplateProcessor, preparationObject);
    assertEquals(0, additionalServices.size());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) DatalakeView(com.sequenceiq.cloudbreak.template.views.DatalakeView) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)48 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)30 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)19 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)18 DisplayName (org.junit.jupiter.api.DisplayName)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)15 ArrayList (java.util.ArrayList)14 Test (org.junit.jupiter.api.Test)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 List (java.util.List)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Set (java.util.Set)9 Collectors (java.util.stream.Collectors)9 Optional (java.util.Optional)8