use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.
the class AzureClient method validateNetworkLinkExistenceForDnsZones.
public ValidationResult validateNetworkLinkExistenceForDnsZones(String networkLinkId, List<AzurePrivateDnsZoneServiceEnum> services, String resourceGroupName) {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
PagedList<PrivateZone> privateDnsZoneList = getPrivateDnsZoneList();
for (AzurePrivateDnsZoneServiceEnum service : services) {
String dnsZoneName = service.getDnsZoneName();
Optional<PrivateZone> privateZoneWithNetworkLink = privateDnsZoneList.stream().filter(privateZone -> !privateZone.resourceGroupName().equalsIgnoreCase(resourceGroupName)).filter(privateZone -> privateZone.name().equalsIgnoreCase(dnsZoneName)).filter(privateZone -> privateZone.provisioningState().equals(SUCCEEDED)).filter(privateZone -> Objects.nonNull(getNetworkLinkByPrivateDnsZone(privateZone.resourceGroupName(), dnsZoneName, networkLinkId))).findFirst();
if (privateZoneWithNetworkLink.isPresent()) {
PrivateZone privateZone = privateZoneWithNetworkLink.get();
String validationMessage = String.format("Network link for the network %s already exists for Private DNS Zone %s in resource group %s. " + "Please ensure that there is no existing network link and try again!", networkLinkId, dnsZoneName, privateZone.resourceGroupName());
LOGGER.warn(validationMessage);
resultBuilder.error(validationMessage);
}
}
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.
the class AzureClient method checkIfNetworkLinksDeployed.
public boolean checkIfNetworkLinksDeployed(String resourceGroupName, String networkId, List<AzurePrivateDnsZoneServiceEnum> services) {
LOGGER.debug("Checking Network link between network and services {} and network link {}", networkId, services.stream().map(AzurePrivateDnsZoneServiceEnum::getDnsZoneName).collect(Collectors.toList()));
for (AzurePrivateDnsZoneServiceEnum service : services) {
String dnsZoneName = service.getDnsZoneName();
PagedList<VirtualNetworkLinkInner> virtualNetworkLinks = listNetworkLinksByPrivateDnsZoneName(resourceGroupName, dnsZoneName);
if (virtualNetworkLinks.isEmpty()) {
LOGGER.info("Network link for network {} not found for DNS zone {}!", networkId, dnsZoneName);
return false;
} else if (!isNetworkLinkCreated(networkId, virtualNetworkLinks)) {
LOGGER.info("Network link for network {} and DNS Zone {} is not provisioned successfully yet!", networkId, dnsZoneName);
return false;
}
}
return true;
}
use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.
the class AzureClient method checkIfDnsZonesDeployed.
public boolean checkIfDnsZonesDeployed(String resourceGroupName, List<AzurePrivateDnsZoneServiceEnum> services) {
LOGGER.debug("Checking DNS Zones for services {}", services.stream().map(AzurePrivateDnsZoneServiceEnum::getDnsZoneName).collect(Collectors.toList()));
PagedList<PrivateZone> dnsZones = listPrivateDnsZonesByResourceGroup(resourceGroupName);
for (AzurePrivateDnsZoneServiceEnum service : services) {
String dnsZoneName = service.getDnsZoneName();
boolean dnsZoneFound = dnsZones.stream().filter(dnsZone -> dnsZone.name().equals(dnsZoneName)).anyMatch(dnsZone -> dnsZone.provisioningState().equals(SUCCEEDED));
if (!dnsZoneFound) {
LOGGER.info("DNS Zone {} is not provisioned successfully yet!", dnsZoneName);
return false;
}
}
return true;
}
use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZonesServiceTest method testGetServicesWithExistingZonesWhenPostgresWithExistingPrivateDnsZone.
@Test
void testGetServicesWithExistingZonesWhenPostgresWithExistingPrivateDnsZone() {
NetworkDto networkDto = getNetworkDto("postgresPrivateDnsZoneId");
Set<AzurePrivateDnsZoneServiceEnum> servicesWithPrivateDnsZones = underTest.getServicesWithExistingZones(networkDto);
assertThat(servicesWithPrivateDnsZones).hasSize(1);
assertThat(servicesWithPrivateDnsZones).contains(AzurePrivateDnsZoneServiceEnum.POSTGRES);
}
use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZonesServiceTest method testGetServicesWithExistingZonesWhenNoServicesWithExistingPrivateDnsZone.
@Test
void testGetServicesWithExistingZonesWhenNoServicesWithExistingPrivateDnsZone() {
NetworkDto networkDto = getNetworkDto(null);
Set<AzurePrivateDnsZoneServiceEnum> servicesWithPrivateDnsZones = underTest.getServicesWithExistingZones(networkDto);
assertThat(servicesWithPrivateDnsZones).isEmpty();
}
Aggregations