use of com.cloudera.api.swagger.model.ApiDataContextRef in project cloudbreak by hortonworks.
the class CmTemplateProcessor method addInstantiator.
public void addInstantiator(ClouderaManagerRepo clouderaManagerRepoDetails, TemplatePreparationObject templatePreparationObject, String sdxContextName) {
ApiClusterTemplateInstantiator instantiator = ofNullable(cmTemplate.getInstantiator()).orElseGet(ApiClusterTemplateInstantiator::new);
if (instantiator.getClusterName() == null) {
instantiator.setClusterName(templatePreparationObject.getGeneralClusterConfigs().getClusterName());
}
addCmVersionDependantConfigs(clouderaManagerRepoDetails, templatePreparationObject, instantiator);
for (ApiClusterTemplateService service : ofNullable(cmTemplate.getServices()).orElse(List.of())) {
List<String> nonBaseRefs = ofNullable(service.getRoleConfigGroups()).orElse(List.of()).stream().filter(rcg -> rcg.getBase() == null || !rcg.getBase()).map(ApiClusterTemplateRoleConfigGroup::getRefName).collect(Collectors.toList());
for (String nonBaseRef : nonBaseRefs) {
instantiator.addRoleConfigGroupsItem(new ApiClusterTemplateRoleConfigGroupInfo().rcgRefName(nonBaseRef));
}
}
ofNullable(sdxContextName).map(name -> List.of(new ApiDataContextRef().name(name))).map(apiDataContextRefs -> new ApiClusterTemplateClusterSpec().dataContextRefs(apiDataContextRefs)).ifPresent(instantiator::clusterSpec);
cmTemplate.setInstantiator(instantiator);
}
Aggregations