use of com.sequenceiq.freeipa.api.v1.dns.model.AddDnsZoneForSubnetsResponse 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.AddDnsZoneForSubnetsResponse in project cloudbreak by hortonworks.
the class DnsZoneService method addDnsZonesForSubnets.
@Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION))
public AddDnsZoneForSubnetsResponse addDnsZonesForSubnets(AddDnsZoneForSubnetsRequest request, String accountId) throws FreeIpaClientException {
FreeIpaClient client = getFreeIpaClient(request.getEnvironmentCrn(), accountId);
AddDnsZoneForSubnetsResponse response = new AddDnsZoneForSubnetsResponse();
for (String subnet : request.getSubnets()) {
try {
LOGGER.info("Add subnet's [{}] reverse DNS zone", subnet);
client.addReverseDnsZone(subnet);
response.getSuccess().add(subnet);
LOGGER.debug("Subnet [{}] added", subnet);
} catch (RetryableFreeIpaClientException e) {
throw e;
} catch (FreeIpaClientException e) {
LOGGER.warn("Can't add subnet's [{}] reverse DNS zone", subnet, e);
response.getFailed().put(subnet, e.getMessage());
}
}
return response;
}
Aggregations