use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class KerberosConfigV1Service method getKerberosConfigIfFreeIPAExists.
private DescribeKerberosConfigResponse getKerberosConfigIfFreeIPAExists(String environmentCrn, String accountId, String clusterName, Stack stack) throws FreeIpaClientException {
MDCBuilder.buildMdcContext(stack);
LOGGER.debug("Get kerberos config when FreeIPA exists for env");
Optional<KerberosConfig> existingKerberosConfig = kerberosConfigService.find(environmentCrn, accountId, clusterName);
KerberosConfig kerberosConfig;
if (existingKerberosConfig.isPresent()) {
LOGGER.debug("Kerberos config already exists");
kerberosConfig = existingKerberosConfig.get();
} else {
kerberosConfig = createNewKerberosConfig(environmentCrn, clusterName, stack, false);
}
return convertKerberosConfigToDescribeKerberosConfigResponse(kerberosConfig);
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class KerberosConfigRegisterService method createKerberosConfig.
public KerberosConfig createKerberosConfig(Long stackId, String dn, String password, String clusterName, String environmentCrn) {
FreeIpa freeIpa = getFreeIpaService().findByStackId(stackId);
Stack stack = getStackWithInstanceMetadata(stackId);
if (StringUtils.isEmpty(environmentCrn)) {
environmentCrn = stack.getEnvironmentCrn();
}
KerberosConfig kerberosConfig = new KerberosConfig();
kerberosConfig.setDomain(freeIpa.getDomain());
kerberosConfig.setEnvironmentCrn(environmentCrn);
kerberosConfig.setName(stack.getName());
kerberosConfig.setPrincipal(dn);
kerberosConfig.setRealm(freeIpa.getDomain().toUpperCase());
kerberosConfig.setType(KerberosType.FREEIPA);
Set<InstanceMetaData> allNotDeletedInstances = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getNotDeletedInstanceMetaDataSet().stream()).collect(Collectors.toSet());
String allFreeIpaIpJoined = allNotDeletedInstances.stream().map(InstanceMetaData::getPrivateIp).collect(Collectors.joining(","));
kerberosConfig.setNameServers(allFreeIpaIpJoined);
addServerAddress(freeIpa, stack, kerberosConfig, allNotDeletedInstances);
kerberosConfig.setPassword(StringUtils.isBlank(password) ? freeIpa.getAdminPassword() : password);
kerberosConfig.setClusterName(clusterName);
return kerberosConfigService.createKerberosConfig(kerberosConfig, stack.getAccountId());
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class KerberosConfigUpdateService method updateNameservers.
public void updateNameservers(Long stackId) {
Stack stack = getStackWithInstanceMetadata(stackId);
String environmentCrn = stack.getEnvironmentCrn();
Set<InstanceMetaData> allNotDeletedInstances = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getNotDeletedInstanceMetaDataSet().stream()).collect(Collectors.toSet());
String allFreeIpaIpJoined = allNotDeletedInstances.stream().map(InstanceMetaData::getPrivateIp).collect(Collectors.joining(","));
List<KerberosConfig> kerberosConfigs = kerberosConfigService.findAllInEnvironment(environmentCrn);
kerberosConfigs.forEach(kerberosConfig -> {
kerberosConfig.setNameServers(allFreeIpaIpJoined);
});
kerberosConfigService.saveAll(kerberosConfigs);
}
Aggregations