Search in sources :

Example 6 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessorTest method testAddRoleConfigsWithNoMatchinRefName.

@Test
public void testAddRoleConfigsWithNoMatchinRefName() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager.bp"));
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    configs.put("hdfs-NAMENODE-nomatch", List.of(new ApiClusterTemplateConfig().name("dfs_name_dir_list").variable("master_NAMENODE")));
    configs.put("hdfs-DATANODE-nomatch", List.of(new ApiClusterTemplateConfig().name("dfs_data_dir_list").variable("worker_DATANODE")));
    underTest.addRoleConfigs("HDFS", configs);
    ApiClusterTemplateService service = underTest.getTemplate().getServices().stream().filter(srv -> "HDFS".equals(srv.getServiceType())).findAny().get();
    ApiClusterTemplateRoleConfigGroup dn = service.getRoleConfigGroups().stream().filter(rcg -> "DATANODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> dnConfigs = dn.getConfigs();
    ApiClusterTemplateRoleConfigGroup nn = service.getRoleConfigGroups().stream().filter(rcg -> "NAMENODE".equals(rcg.getRoleType())).findAny().get();
    List<ApiClusterTemplateConfig> nnConfigs = nn.getConfigs();
    assertNull(nnConfigs);
    assertNull(dnConfigs);
}
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) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 7 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessorTest method testIfCustomRoleConfigsMapIsRetrievedCorrectly.

@Test
void testIfCustomRoleConfigsMapIsRetrievedCorrectly() {
    underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
    Map<String, List<ApiClusterTemplateRoleConfigGroup>> expectedMap = new HashMap<>();
    Set<CustomConfigurationPropertyView> configs = Set.of(new CustomConfigurationPropertyView("property3", "value3", "role3", "service2"), new CustomConfigurationPropertyView("property2", "value2", "role2", "service1"), new CustomConfigurationPropertyView("property4", "value4", null, "service1"));
    expectedMap.put("service2", List.of(new ApiClusterTemplateRoleConfigGroup().roleType("role3").addConfigsItem(new ApiClusterTemplateConfig().name("property3").value("value3"))));
    expectedMap.put("service1", List.of(new ApiClusterTemplateRoleConfigGroup().roleType("role2").addConfigsItem(new ApiClusterTemplateConfig().name("property2").value("value2"))));
    assertEquals(expectedMap, underTest.getCustomRoleConfigsMap(configs));
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArrayList(java.util.ArrayList) List(java.util.List) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Test(org.junit.jupiter.api.Test)

Example 8 with ApiClusterTemplateRoleConfigGroup

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

the class CentralCmTemplateUpdaterTest method configsAreInjected.

@Test
public void configsAreInjected() {
    List<ApiClusterTemplateConfig> serviceConfigs = List.of(config("service_config_name", "service_config_value"));
    List<ApiClusterTemplateConfig> roleConfigs = List.of(config("role_config_name", "role_config_value"));
    ReflectionTestUtils.setField(cmTemplateConfigInjectorProcessor, "injectors", List.of(new CmTemplateConfigInjector() {

        @Override
        public List<ApiClusterTemplateConfig> getServiceConfigs(ApiClusterTemplateService service, TemplatePreparationObject source) {
            return serviceConfigs;
        }

        @Override
        public List<ApiClusterTemplateConfig> getRoleConfigs(ApiClusterTemplateRoleConfigGroup roleConfigGroup, ApiClusterTemplateService service, TemplatePreparationObject source) {
            return roleConfigs;
        }
    }));
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/namenode-ha.bp"));
    ApiClusterTemplate generated = testGetCmTemplate();
    assertMatchesBlueprintAtPath("output/namenode-ha-injected.bp", generated);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.Test)

Example 9 with ApiClusterTemplateRoleConfigGroup

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

the class RangerRazBaseConfigProvider method createTemplate.

protected ApiClusterTemplateService createTemplate() {
    ApiClusterTemplateService coreSettings = new ApiClusterTemplateService().serviceType(RANGER_RAZ).refName("ranger-RANGER_RAZ");
    ApiClusterTemplateRoleConfigGroup coreSettingsRole = new ApiClusterTemplateRoleConfigGroup().roleType(RANGER_RAZ_SERVER).base(true).refName("ranger-RANGER_RAZ_SERVER");
    coreSettings.roleConfigGroups(List.of(coreSettingsRole));
    return coreSettings;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Example 10 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateConfigInjectorProcessor method process.

public void process(CmTemplateProcessor processor, TemplatePreparationObject source) {
    List<ApiClusterTemplateService> services = ofNullable(processor.getTemplate().getServices()).orElse(List.of());
    for (CmTemplateConfigInjector injector : injectors) {
        for (ApiClusterTemplateService service : services) {
            injector.addServiceConfigs(service, processor, source);
            Iterable<ApiClusterTemplateRoleConfigGroup> roleConfigGroups = ofNullable(service.getRoleConfigGroups()).orElse(List.of());
            for (ApiClusterTemplateRoleConfigGroup roleConfigGroup : roleConfigGroups) {
                injector.addRoleConfigs(roleConfigGroup, service, processor, source);
            }
        }
    }
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Aggregations

ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)22 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 HashMap (java.util.HashMap)10 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)9 Test (org.junit.jupiter.api.Test)8 ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)5 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)5 CustomConfigurationPropertyView (com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView)5 HashSet (java.util.HashSet)5 Map (java.util.Map)5 Optional (java.util.Optional)5 ApiClusterTemplateHostTemplate (com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)4 ApiClusterTemplateInstantiator (com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator)4 ApiClusterTemplateRoleConfigGroupInfo (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo)4 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)4 ApiClusterTemplateHostInfo (com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3