use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZoneConnectedToNetworkWhenNotConnectedToEnvironmentNetwork.
@Test
void testPrivateDnsZoneConnectedToNetworkWhenNotConnectedToEnvironmentNetwork() {
ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
Network network = getNetwork();
when(azureClient.getNetworkByResourceGroup(NETWORK_RESOURCE_GROUP_NAME, NETWORK_NAME)).thenReturn(network);
PagedList<VirtualNetworkLinkInner> virtualNetworkLinks = getNetworkLinks(List.of("anotherNetwork"));
when(azureClient.listNetworkLinksByPrivateDnsZoneName(SUBSCRIPTION_ID, A_RESOURCE_GROUP_NAME, ZONE_NAME_POSTGRES)).thenReturn(virtualNetworkLinks);
resultBuilder = underTest.privateDnsZoneConnectedToNetwork(azureClient, NETWORK_RESOURCE_GROUP_NAME, NETWORK_NAME, getPrivateDnsZoneResourceId(A_RESOURCE_GROUP_NAME), resultBuilder);
assertTrue(resultBuilder.build().hasError());
ValidationTestUtil.checkErrorsPresent(resultBuilder, List.of("The private DNS zone /subscriptions/subscriptionId/resourceGroups/a-resource-group-name/providers/Microsoft.Network/privateDnsZones" + "/privatelink.postgres.database.azure.com does not have a network link to network networkName. Please make sure the private DNS zone " + "is connected to the network provided to the environment."));
}
use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzureNetworkLinkService method createMissingNetworkLinks.
private void createMissingNetworkLinks(AzureClient azureClient, String azureNetworkId, String resourceGroup, Map<String, String> tags, List<AzurePrivateDnsZoneServiceEnum> enabledPrivateEndpointServices) {
for (AzurePrivateDnsZoneServiceEnum service : enabledPrivateEndpointServices) {
PagedList<VirtualNetworkLinkInner> networkLinks = azureClient.listNetworkLinksByPrivateDnsZoneName(resourceGroup, service.getDnsZoneName());
boolean networkLinkCreated = azureClient.isNetworkLinkCreated(StringUtils.substringAfterLast(azureNetworkId, "/"), networkLinks);
if (!networkLinkCreated) {
LOGGER.debug("Network links for service {} not yet created, creating them now", service.getSubResource());
AzureDnsZoneDeploymentParameters parameters = new AzureDnsZoneDeploymentParameters(azureNetworkId, true, enabledPrivateEndpointServices, resourceGroup, tags);
azureResourceDeploymentHelperService.deployTemplate(azureClient, parameters);
}
}
}
Aggregations