use of com.sequenceiq.freeipa.entity.FreeIpa 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.entity.FreeIpa in project cloudbreak by hortonworks.
the class LdapConfigRegisterService method createLdapConfig.
public LdapConfig createLdapConfig(Long stackId, String bindDn, String bindPassword, String clusterName, String environmentCrn) {
Stack stack = getStackWithInstanceMetadata(stackId);
if (StringUtils.isEmpty(environmentCrn)) {
environmentCrn = stack.getEnvironmentCrn();
}
FreeIpa freeIpa = getFreeIpaService().findByStackId(stackId);
String adminGroupName = StringUtils.isNotEmpty(freeIpa.getAdminGroupName()) ? freeIpa.getAdminGroupName() : "";
LdapConfig ldapConfig = new LdapConfig();
ldapConfig.setName(stack.getName());
ldapConfig.setEnvironmentCrn(environmentCrn);
ldapConfig.setAdminGroup(adminGroupName);
ldapConfig.setUserGroup(USER_GROUP);
String domainComponent = generateDomainComponent(freeIpa);
ldapConfig.setBindDn(StringUtils.isBlank(bindDn) ? BIND_DN + domainComponent : bindDn);
ldapConfig.setUserSearchBase(USER_SEARCH_BASE + domainComponent);
ldapConfig.setGroupSearchBase(GROUP_SEARCH_BASE + domainComponent);
ldapConfig.setUserDnPattern(USER_DN_PATTERN + domainComponent);
addServerHost(stack, freeIpa, ldapConfig);
ldapConfig.setProtocol(PROTOCOL);
ldapConfig.setServerPort(SERVER_PORT);
ldapConfig.setDomain(freeIpa.getDomain());
ldapConfig.setBindPassword(StringUtils.isBlank(bindPassword) ? freeIpa.getAdminPassword() : bindPassword);
ldapConfig.setDirectoryType(DirectoryType.LDAP);
ldapConfig.setUserNameAttribute(USER_NAME_ATTRIBUTE);
ldapConfig.setUserObjectClass(USER_OBJECT_CLASS);
ldapConfig.setGroupMemberAttribute(GROUP_MEMBER_ATTRIBUTE);
ldapConfig.setGroupNameAttribute(GROUP_NAME_ATTRIBUTE);
ldapConfig.setGroupObjectClass(GROUP_OBJECT_CLASS);
ldapConfig.setClusterName(clusterName);
return ldapConfigService.createLdapConfig(ldapConfig, stack.getAccountId());
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class ClusterProxyService method registerFreeIpa.
private Optional<ConfigRegistrationResponse> registerFreeIpa(Stack stack, List<String> instanceIdsToRegister, boolean bootstrap, boolean waitForGoodHealth) {
MDCBuilder.buildMdcContext(stack);
if (!clusterProxyEnablementService.isClusterProxyApplicable(stack.getCloudPlatform())) {
LOGGER.debug("Cluster Proxy integration disabled. Skipping registering FreeIpa [{}]", stack);
return Optional.empty();
}
LOGGER.debug("Registering freeipa with cluster-proxy: Environment CRN = [{}], Stack CRN = [{}], bootstrap: [{}], waitForGoodHealth: [{}]", stack.getEnvironmentCrn(), stack.getResourceCrn(), bootstrap, waitForGoodHealth);
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getNotDeletedGatewayConfigs(stack);
ClientCertificate clientCertificate = clientCertificates(stack);
boolean preferPrivateIp = stack.getTunnel().useCcm();
List<GatewayConfig> tunnelGatewayConfigs;
List<ClusterServiceConfig> serviceConfigs = new LinkedList<>();
serviceConfigs.add(createServiceConfig(stack, FREEIPA_SERVICE_NAME, primaryGatewayConfig, clientCertificate, preferPrivateIp));
if (bootstrap) {
tunnelGatewayConfigs = List.of(primaryGatewayConfig);
serviceConfigs.add(createServiceConfig(stack, generateFreeIpaFqdn(stack), primaryGatewayConfig, clientCertificate, preferPrivateIp));
} else if (clusterProxyServiceAvailabilityChecker.isDnsBasedServiceNameAvailable(stack)) {
List<GatewayConfig> targetGatewayConfigs = gatewayConfigs.stream().filter(gatewayConfig -> Objects.nonNull(gatewayConfig.getInstanceId())).filter(gatewayConfig -> Objects.isNull(instanceIdsToRegister) || instanceIdsToRegister.contains(gatewayConfig.getInstanceId())).collect(Collectors.toList());
serviceConfigs.addAll(createDnsMappedServiceConfigs(stack, targetGatewayConfigs, clientCertificate, preferPrivateIp));
tunnelGatewayConfigs = targetGatewayConfigs;
} else {
tunnelGatewayConfigs = List.of(primaryGatewayConfig);
}
ConfigRegistrationRequestBuilder requestBuilder = new ConfigRegistrationRequestBuilder(stack.getResourceCrn()).withServices(serviceConfigs).withAccountId(stack.getAccountId());
if (stack.getTunnel().useCcmV1()) {
requestBuilder.withTunnelEntries(createTunnelEntries(stack, tunnelGatewayConfigs));
} else if (stack.getTunnel().useCcmV2OrJumpgate()) {
requestBuilder.withCcmV2Entries(createCcmV2Configs(stack, tunnelGatewayConfigs));
}
ConfigRegistrationRequest request = requestBuilder.build();
LOGGER.debug("Registering cluster proxy configuration [{}]", request);
ConfigRegistrationResponse response = clusterProxyRegistrationClient.registerConfig(request);
if (waitForGoodHealth) {
pollForGoodHealth(stack);
}
stackUpdater.updateClusterProxyRegisteredFlag(stack, true);
return Optional.of(response);
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class FreeIpaCreationService method launchFreeIpa.
public DescribeFreeIpaResponse launchFreeIpa(CreateFreeIpaRequest request, String accountId) {
String userCrn = crnService.getUserCrn();
Future<String> ownerFuture = initiateOwnerFetching(userCrn);
Credential credential = credentialService.getCredentialByEnvCrn(request.getEnvironmentCrn());
DetailedEnvironmentResponse environment = measure(() -> cachedEnvironmentClientService.getByCrn(request.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
Stack stack = stackConverter.convert(request, environment, accountId, ownerFuture, userCrn, credential.getCloudPlatform());
stack.setAppVersion(appVersion);
GetPlatformTemplateRequest getPlatformTemplateRequest = templateService.triggerGetTemplate(stack, credential);
Telemetry telemetry = stack.getTelemetry();
if (telemetry != null) {
telemetry.setRules(accountTelemetryService.getAnonymizationRules(accountId));
}
cloudStorageFolderResolverService.updateStorageLocation(telemetry, FluentClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
stack.setTelemetry(telemetry);
Backup backup = stack.getBackup();
backup = cloudBackupFolderResolverService.updateStorageLocation(backup, BackupClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
stack.setBackup(backup);
fillInstanceMetadata(stack, environment);
String template = templateService.waitGetTemplate(getPlatformTemplateRequest);
stack.setTemplate(template);
SecurityConfig securityConfig = tlsSecurityService.generateSecurityKeys(accountId);
multiAzValidator.validateMultiAzForStack(stack.getPlatformvariant(), stack.getInstanceGroups());
freeIpaRecommendationService.validateCustomInstanceType(stack, credential);
try {
Triple<Stack, ImageEntity, FreeIpa> stackImageFreeIpaTuple = transactionService.required(() -> {
SecurityConfig savedSecurityConfig = securityConfigService.save(securityConfig);
stack.setSecurityConfig(savedSecurityConfig);
Stack savedStack = stackService.save(stack);
ImageSettingsRequest imageSettingsRequest = request.getImage();
ImageEntity image = imageService.create(savedStack, Objects.nonNull(imageSettingsRequest) ? imageSettingsRequest : new ImageSettingsRequest());
FreeIpa freeIpa = freeIpaService.create(savedStack, request.getFreeIpa());
return Triple.of(savedStack, image, freeIpa);
});
flowManager.notify(FlowChainTriggers.PROVISION_TRIGGER_EVENT, new StackEvent(FlowChainTriggers.PROVISION_TRIGGER_EVENT, stackImageFreeIpaTuple.getLeft().getId()));
InMemoryStateStore.putStack(stack.getId(), PollGroup.POLLABLE);
return stackToDescribeFreeIpaResponseConverter.convert(stackImageFreeIpaTuple.getLeft(), stackImageFreeIpaTuple.getMiddle(), stackImageFreeIpaTuple.getRight(), Optional.empty(), false);
} catch (TransactionService.TransactionExecutionException e) {
LOGGER.error("Creation of FreeIPA failed", e);
throw new BadRequestException("Creation of FreeIPA failed: " + e.getCause().getMessage(), e);
}
}
use of com.sequenceiq.freeipa.entity.FreeIpa in project cloudbreak by hortonworks.
the class CcmUserDataService method getGatewayFqdn.
private String getGatewayFqdn(Stack stack) {
FreeIpa freeIpa = freeIpaService.findByStack(stack);
String gatewayHostName = hostDiscoveryService.generateHostname(freeIpa.getHostname(), null, 0, false);
return hostDiscoveryService.determineGatewayFqdn(gatewayHostName, freeIpa.getDomain());
}
Aggregations