use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner 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.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzureClient method listNetworkLinksByPrivateDnsZoneName.
public PagedList<VirtualNetworkLinkInner> listNetworkLinksByPrivateDnsZoneName(String subscriptionId, String resourceGroupName, String dnsZoneName) {
privatednsManager dnsManager = azureClientCredentials.getPrivateDnsManagerWithAnotherSubscription(subscriptionId);
PagedList<VirtualNetworkLinkInner> virtualNetworkLinks = dnsManager.virtualNetworkLinks().inner().list(resourceGroupName, dnsZoneName);
virtualNetworkLinks.loadAll();
return virtualNetworkLinks;
}
use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZonesNotConnectedToNetworkWhenZoneConnected.
@Test
void testPrivateDnsZonesNotConnectedToNetworkWhenZoneConnected() {
ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
PagedList<PrivateZone> privateDnsZoneList = getPrivateDnsZones(A_RESOURCE_GROUP_NAME, List.of(ZONE_NAME_POSTGRES), ProvisioningState.SUCCEEDED);
when(azureClient.getNetworkLinkByPrivateDnsZone(A_RESOURCE_GROUP_NAME, ZONE_NAME_POSTGRES, NETWORK_NAME)).thenReturn(new VirtualNetworkLinkInner());
ValidationResult result = underTest.privateDnsZonesNotConnectedToNetwork(azureClient, NETWORK_NAME, SINGLE_RESOURCE_GROUP_NAME, ZONE_NAME_POSTGRES, resultBuilder, privateDnsZoneList);
assertTrue(result.hasError());
ValidationTestUtil.checkErrorsPresent(resultBuilder, List.of("Network link for the network networkName already exists for Private DNS Zone " + "privatelink.postgres.database.azure.com in resource group a-resource-group-name. Please ensure that there is no existing network link and " + "try again!"));
}
use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzurePrivateDnsZoneValidatorServiceTest method getNetworkLinks.
private PagedList<VirtualNetworkLinkInner> getNetworkLinks(List<String> foundNetworkIds) {
PagedList<VirtualNetworkLinkInner> virtualNetworkLinks = new TestPagedList<>();
foundNetworkIds.stream().map(id -> new VirtualNetworkLinkInner().withVirtualNetwork(new SubResource().withId(id))).forEach(virtualNetworkLinks::add);
return virtualNetworkLinks;
}
use of com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner in project cloudbreak by hortonworks.
the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZoneConnectedToNetworkWhenConnectedToEnvironmentNetwork.
@Test
void testPrivateDnsZoneConnectedToNetworkWhenConnectedToEnvironmentNetwork() {
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(NETWORK_RESOURCE_ID));
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);
assertFalse(resultBuilder.build().hasError());
}
Aggregations