Search in sources :

Example 6 with VirtualNetworkLinkInner

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."));
}
Also used : Network(com.microsoft.azure.management.network.Network) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with VirtualNetworkLinkInner

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);
        }
    }
}
Also used : AzureDnsZoneDeploymentParameters(com.sequenceiq.cloudbreak.cloud.azure.connector.resource.AzureDnsZoneDeploymentParameters) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)

Aggregations

VirtualNetworkLinkInner (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)7 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)4 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Network (com.microsoft.azure.management.network.Network)3 PrivateZone (com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)2 AzurePrivateDnsZoneServiceEnum (com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)2 PagedList (com.microsoft.azure.PagedList)1 SubResource (com.microsoft.azure.SubResource)1 ProvisioningState (com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState)1 com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager)1 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)1 AzureDnsZoneDeploymentParameters (com.sequenceiq.cloudbreak.cloud.azure.connector.resource.AzureDnsZoneDeploymentParameters)1 ValidationTestUtil (com.sequenceiq.cloudbreak.cloud.azure.validator.ValidationTestUtil)1 A_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.A_RESOURCE_GROUP_NAME)1 NETWORK_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_NAME)1 NETWORK_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_GROUP_NAME)1 NETWORK_RESOURCE_ID (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.NETWORK_RESOURCE_ID)1 SINGLE_RESOURCE_GROUP_NAME (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.SINGLE_RESOURCE_GROUP_NAME)1 TestPagedList (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList)1