use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetIdsRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method createFreeIpa.
private void createFreeIpa(Event<EnvironmentDto> environmentDtoEvent, EnvironmentDto environmentDto) throws Exception {
Optional<DescribeFreeIpaResponse> freeIpa = freeIpaService.describe(environmentDto.getResourceCrn());
if (freeIpa.isEmpty()) {
LOGGER.info("FreeIpa for environmentCrn '{}' was not found, creating a new one.", environmentDto.getResourceCrn());
CreateFreeIpaRequest createFreeIpaRequest = createFreeIpaRequest(environmentDto);
freeIpaService.create(createFreeIpaRequest);
awaitFreeIpaCreation(environmentDtoEvent, environmentDto);
AddDnsZoneForSubnetIdsRequest addDnsZoneForSubnetIdsRequest = addDnsZoneForSubnetIdsRequest(environmentDto);
if (shouldSendSubnetIdsToFreeIpa(addDnsZoneForSubnetIdsRequest)) {
dnsV1Endpoint.addDnsZoneForSubnetIds(addDnsZoneForSubnetIdsRequest);
}
} else {
LOGGER.info("FreeIpa for environmentCrn '{}' already exists. Using this one.", environmentDto.getResourceCrn());
if (CREATE_IN_PROGRESS == freeIpa.get().getStatus()) {
awaitFreeIpaCreation(environmentDtoEvent, environmentDto);
}
}
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetIdsRequest in project cloudbreak by hortonworks.
the class DnsZoneService method addDnsZonesForSubnetIds.
@Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION))
public AddDnsZoneForSubnetsResponse addDnsZonesForSubnetIds(AddDnsZoneForSubnetIdsRequest request, String accountId) throws FreeIpaClientException {
Stack stack = stackService.getByEnvironmentCrnAndAccountId(request.getEnvironmentCrn(), accountId);
MDCBuilder.buildMdcContext(stack);
Multimap<String, String> subnetWithCidr = networkService.getFilteredSubnetWithCidr(request.getEnvironmentCrn(), stack, request.getAddDnsZoneNetwork().getNetworkId(), request.getAddDnsZoneNetwork().getSubnetIds());
FreeIpaClient client = freeIpaClientFactory.getFreeIpaClientForStack(stack);
AddDnsZoneForSubnetsResponse response = new AddDnsZoneForSubnetsResponse();
for (Entry<String, String> subnet : subnetWithCidr.entries()) {
try {
LOGGER.info("Add subnet's [{}] reverse DNS zone", subnet);
String subnetCidr = subnet.getValue();
Set<DnsZone> dnsZones = client.findDnsZone(subnetCidr);
if (dnsZones.isEmpty()) {
LOGGER.debug("Subnet reverse DNS zone does not exists [{}], add it now", subnet);
client.addReverseDnsZone(subnetCidr);
response.getSuccess().add(subnet.getKey());
LOGGER.debug("Subnet [{}] added", subnet);
}
} catch (RetryableFreeIpaClientException e) {
throw e;
} catch (FreeIpaClientException e) {
LOGGER.warn("Can't add subnet's [{}] reverse DNS zone with cidr [{}]", subnet, subnet.getValue(), e);
response.getFailed().putIfAbsent(subnet.getKey(), e.getMessage());
}
}
return response;
}
use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetIdsRequest in project cloudbreak by hortonworks.
the class FreeIpaCreationHandler method addDnsZoneForSubnetIdsRequest.
private AddDnsZoneForSubnetIdsRequest addDnsZoneForSubnetIdsRequest(EnvironmentDto environmentDto) {
AddDnsZoneForSubnetIdsRequest addDnsZoneForSubnetIdsRequest = new AddDnsZoneForSubnetIdsRequest();
addDnsZoneForSubnetIdsRequest.setEnvironmentCrn(environmentDto.getResourceCrn());
AddDnsZoneNetwork addDnsZoneNetwork = new AddDnsZoneNetwork();
addDnsZoneNetwork.setNetworkId(environmentDto.getNetwork().getNetworkId());
addDnsZoneNetwork.setSubnetIds(environmentDto.getNetwork().getSubnetIds());
addDnsZoneForSubnetIdsRequest.setAddDnsZoneNetwork(addDnsZoneNetwork);
return addDnsZoneForSubnetIdsRequest;
}
Aggregations