Search in sources :

Example 11 with PrivateZone

use of com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZonesNotConnectedToNetworkWhenZoneProvisioningStateNotSucceeded.

@ParameterizedTest
@MethodSource(value = "getAllProvisioningStates")
void testPrivateDnsZonesNotConnectedToNetworkWhenZoneProvisioningStateNotSucceeded(ProvisioningState provisioningState) {
    ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
    PagedList<PrivateZone> privateDnsZoneList = getPrivateDnsZones(A_RESOURCE_GROUP_NAME, List.of(ZONE_NAME_POSTGRES), provisioningState);
    ValidationResult result = underTest.privateDnsZonesNotConnectedToNetwork(azureClient, NETWORK_NAME, SINGLE_RESOURCE_GROUP_NAME, ZONE_NAME_POSTGRES, resultBuilder, privateDnsZoneList);
    assertFalse(result.hasError());
    verify(azureClient, never()).getNetworkLinkByPrivateDnsZone(anyString(), anyString(), anyString());
}
Also used : ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with PrivateZone

use of com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorServiceTest method testPrivateDnsZoneExistsWhenZoneExists.

@Test
void testPrivateDnsZoneExistsWhenZoneExists() {
    ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder();
    PagedList<PrivateZone> privateZones = new TestPagedList<>();
    privateZones.add(getPrivateDnsZone(null, ZONE_NAME_POSTGRES, null));
    when(azureClient.getPrivateDnsZonesByResourceGroup(SUBSCRIPTION_ID, SINGLE_RESOURCE_GROUP_NAME)).thenReturn(privateZones);
    resultBuilder = underTest.privateDnsZoneExists(azureClient, getPrivateDnsZoneResourceId(), resultBuilder);
    ValidationResult result = resultBuilder.build();
    assertFalse(result.hasError());
}
Also used : ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) TestPagedList(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.TestPagedList) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with PrivateZone

use of com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone in project cloudbreak by hortonworks.

the class AzurePrivateDnsZoneValidatorService method privateDnsZonesNotConnectedToNetwork.

public ValidationResult privateDnsZonesNotConnectedToNetwork(AzureClient azureClient, String networkId, String resourceGroupName, String dnsZoneName, ValidationResult.ValidationResultBuilder resultBuilder, PagedList<PrivateZone> privateDnsZoneList) {
    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(azureClient.getNetworkLinkByPrivateDnsZone(privateZone.resourceGroupName(), dnsZoneName, networkId))).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!", networkId, dnsZoneName, privateZone.resourceGroupName());
        addValidationError(validationMessage, resultBuilder);
    }
    return resultBuilder.build();
}
Also used : AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Objects(java.util.Objects) List(java.util.List) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner) PagedList(com.microsoft.azure.PagedList) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) ResourceId(com.microsoft.azure.arm.resources.ResourceId) SUCCEEDED(com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState.SUCCEEDED) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)

Aggregations

PrivateZone (com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)13 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Test (org.junit.jupiter.api.Test)6 VirtualNetworkLinkInner (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)4 com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager)4 AzurePrivateDnsZoneServiceEnum (com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)4 PagedList (com.microsoft.azure.PagedList)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Strings (com.google.common.base.Strings)2 CloudException (com.microsoft.azure.CloudException)2 Azure (com.microsoft.azure.management.Azure)2 AvailabilitySet (com.microsoft.azure.management.compute.AvailabilitySet)2 CachingTypes (com.microsoft.azure.management.compute.CachingTypes)2 Disk (com.microsoft.azure.management.compute.Disk)2 DiskEncryptionSetIdentityType (com.microsoft.azure.management.compute.DiskEncryptionSetIdentityType)2 DiskEncryptionSetType (com.microsoft.azure.management.compute.DiskEncryptionSetType)2 DiskSkuTypes (com.microsoft.azure.management.compute.DiskSkuTypes)2 PREMIUM_LRS (com.microsoft.azure.management.compute.DiskSkuTypes.PREMIUM_LRS)2 STANDARD_LRS (com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_LRS)2