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);
}
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));
}
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);
}
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;
}
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);
}
}
}
}
Aggregations