Search in sources :

Example 1 with PrivateZone

use of com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone 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();
}
Also used : VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine) AvailabilityZoneId(com.microsoft.azure.management.resources.fluentcore.arm.AvailabilityZoneId) ComputeManager(com.microsoft.azure.management.compute.implementation.ComputeManager) RoleAssignments(com.microsoft.azure.management.graphrbac.RoleAssignments) ProviderAuthenticationFailedException(com.sequenceiq.cloudbreak.client.ProviderAuthenticationFailedException) LoadBalancingRule(com.microsoft.azure.management.network.LoadBalancingRule) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Azure(com.microsoft.azure.management.Azure) DiskEncryptionSetsInner(com.microsoft.azure.management.compute.implementation.DiskEncryptionSetsInner) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Map(java.util.Map) ProvisioningState(com.microsoft.azure.management.storage.ProvisioningState) AzureAuthExceptionHandler(com.sequenceiq.cloudbreak.cloud.azure.util.AzureAuthExceptionHandler) ListBlobItem(com.microsoft.azure.storage.blob.ListBlobItem) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) CachingTypes(com.microsoft.azure.management.compute.CachingTypes) Set(java.util.Set) CopyState(com.microsoft.azure.storage.blob.CopyState) StorageAccountSkuType(com.microsoft.azure.management.storage.StorageAccountSkuType) Disk(com.microsoft.azure.management.compute.Disk) InvalidKeyException(java.security.InvalidKeyException) DiskInner(com.microsoft.azure.management.compute.implementation.DiskInner) RoleAssignmentInner(com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner) NetworkInterface(com.microsoft.azure.management.network.NetworkInterface) Completable(rx.Completable) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) AzureStatusMapper(com.sequenceiq.cloudbreak.cloud.azure.status.AzureStatusMapper) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) OperatingSystemStateTypes(com.microsoft.azure.management.compute.OperatingSystemStateTypes) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Strings(com.google.common.base.Strings) StorageException(com.microsoft.azure.storage.StorageException) LoadBalancer(com.microsoft.azure.management.network.LoadBalancer) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) CloudPageBlob(com.microsoft.azure.storage.blob.CloudPageBlob) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) Subscription(com.microsoft.azure.management.resources.Subscription) EncryptionSetIdentity(com.microsoft.azure.management.compute.EncryptionSetIdentity) AzureMarketplaceImage(com.sequenceiq.cloudbreak.cloud.azure.image.marketplace.AzureMarketplaceImage) IOException(java.io.IOException) StorageAccounts(com.microsoft.azure.management.storage.StorageAccounts) SourceVault(com.microsoft.azure.management.compute.SourceVault) MarketplaceOrderingManager(com.microsoft.azure.management.marketplaceordering.v2015_06_01.implementation.MarketplaceOrderingManager) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) Identity(com.microsoft.azure.management.msi.Identity) Encryption(com.microsoft.azure.management.compute.Encryption) WithCreate(com.microsoft.azure.management.storage.StorageAccount.DefinitionStages.WithCreate) NetworkSecurityGroups(com.microsoft.azure.management.network.NetworkSecurityGroups) ResourceGroups(com.microsoft.azure.management.resources.ResourceGroups) FrontendIPConfigurationInner(com.microsoft.azure.management.network.implementation.FrontendIPConfigurationInner) STANDARD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_LRS) DiskEncryptionSetIdentityType(com.microsoft.azure.management.compute.DiskEncryptionSetIdentityType) DeploymentOperations(com.microsoft.azure.management.resources.DeploymentOperations) URI(java.net.URI) Vault(com.microsoft.azure.management.keyvault.Vault) ResourceStatus(com.sequenceiq.cloudbreak.cloud.model.ResourceStatus) AvailabilitySet(com.microsoft.azure.management.compute.AvailabilitySet) LoadBalancerFrontend(com.microsoft.azure.management.network.LoadBalancerFrontend) Collection(java.util.Collection) com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) AzureDiskType(com.sequenceiq.cloudbreak.cloud.azure.AzureDiskType) Collectors(java.util.stream.Collectors) DiskStorageAccountTypes(com.microsoft.azure.management.compute.DiskStorageAccountTypes) Objects(java.util.Objects) AgreementTerms(com.microsoft.azure.management.marketplaceordering.v2015_06_01.AgreementTerms) List(java.util.List) VirtualNetworkLinkState(com.microsoft.azure.management.privatedns.v2018_09_01.VirtualNetworkLinkState) IndexableRefreshableWrapperImpl(com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableRefreshableWrapperImpl) NetworkInterfaces(com.microsoft.azure.management.network.NetworkInterfaces) CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) Optional(java.util.Optional) VirtualMachineCustomImage(com.microsoft.azure.management.compute.VirtualMachineCustomImage) AccessPolicy(com.microsoft.azure.management.keyvault.AccessPolicy) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) HasId(com.microsoft.azure.management.resources.fluentcore.arm.models.HasId) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) VirtualMachineInstanceView(com.microsoft.azure.management.compute.VirtualMachineInstanceView) Subnet(com.microsoft.azure.management.network.Subnet) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Kind(com.microsoft.azure.management.storage.Kind) Observable(rx.Observable) HashSet(java.util.HashSet) Network(com.microsoft.azure.management.network.Network) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner) PREMIUM_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.PREMIUM_LRS) PagedList(com.microsoft.azure.PagedList) DiskEncryptionSetType(com.microsoft.azure.management.compute.DiskEncryptionSetType) KeyPermissions(com.microsoft.azure.management.keyvault.KeyPermissions) AccessPolicyEntry(com.microsoft.azure.management.keyvault.AccessPolicyEntry) Collections.emptyMap(java.util.Collections.emptyMap) Deployment(com.microsoft.azure.management.resources.Deployment) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) DiskSkuTypes(com.microsoft.azure.management.compute.DiskSkuTypes) StorageAccountKey(com.microsoft.azure.management.storage.StorageAccountKey) KeyForDiskEncryptionSet(com.microsoft.azure.management.compute.KeyForDiskEncryptionSet) ULTRA_SSD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.ULTRA_SSD_LRS) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) CloudException(com.microsoft.azure.CloudException) STANDARD_SSD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_SSD_LRS) RoleAssignment(com.microsoft.azure.management.graphrbac.RoleAssignment) StorageAccountInner(com.microsoft.azure.management.storage.implementation.StorageAccountInner) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SUCCEEDED(com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState.SUCCEEDED) Collections(java.util.Collections) DiskEncryptionSetInner(com.microsoft.azure.management.compute.implementation.DiskEncryptionSetInner) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)

Example 2 with PrivateZone

use of com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone 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;
}
Also used : VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine) AvailabilityZoneId(com.microsoft.azure.management.resources.fluentcore.arm.AvailabilityZoneId) ComputeManager(com.microsoft.azure.management.compute.implementation.ComputeManager) RoleAssignments(com.microsoft.azure.management.graphrbac.RoleAssignments) ProviderAuthenticationFailedException(com.sequenceiq.cloudbreak.client.ProviderAuthenticationFailedException) LoadBalancingRule(com.microsoft.azure.management.network.LoadBalancingRule) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) Azure(com.microsoft.azure.management.Azure) DiskEncryptionSetsInner(com.microsoft.azure.management.compute.implementation.DiskEncryptionSetsInner) Map(java.util.Map) ProvisioningState(com.microsoft.azure.management.storage.ProvisioningState) AzureAuthExceptionHandler(com.sequenceiq.cloudbreak.cloud.azure.util.AzureAuthExceptionHandler) ListBlobItem(com.microsoft.azure.storage.blob.ListBlobItem) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) CachingTypes(com.microsoft.azure.management.compute.CachingTypes) Set(java.util.Set) CopyState(com.microsoft.azure.storage.blob.CopyState) StorageAccountSkuType(com.microsoft.azure.management.storage.StorageAccountSkuType) Disk(com.microsoft.azure.management.compute.Disk) InvalidKeyException(java.security.InvalidKeyException) DiskInner(com.microsoft.azure.management.compute.implementation.DiskInner) RoleAssignmentInner(com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner) NetworkInterface(com.microsoft.azure.management.network.NetworkInterface) Completable(rx.Completable) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) AzureStatusMapper(com.sequenceiq.cloudbreak.cloud.azure.status.AzureStatusMapper) VirtualMachineDataDisk(com.microsoft.azure.management.compute.VirtualMachineDataDisk) OperatingSystemStateTypes(com.microsoft.azure.management.compute.OperatingSystemStateTypes) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Strings(com.google.common.base.Strings) StorageException(com.microsoft.azure.storage.StorageException) LoadBalancer(com.microsoft.azure.management.network.LoadBalancer) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) CloudPageBlob(com.microsoft.azure.storage.blob.CloudPageBlob) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) Subscription(com.microsoft.azure.management.resources.Subscription) EncryptionSetIdentity(com.microsoft.azure.management.compute.EncryptionSetIdentity) AzureMarketplaceImage(com.sequenceiq.cloudbreak.cloud.azure.image.marketplace.AzureMarketplaceImage) IOException(java.io.IOException) StorageAccounts(com.microsoft.azure.management.storage.StorageAccounts) SourceVault(com.microsoft.azure.management.compute.SourceVault) MarketplaceOrderingManager(com.microsoft.azure.management.marketplaceordering.v2015_06_01.implementation.MarketplaceOrderingManager) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) Identity(com.microsoft.azure.management.msi.Identity) Encryption(com.microsoft.azure.management.compute.Encryption) WithCreate(com.microsoft.azure.management.storage.StorageAccount.DefinitionStages.WithCreate) NetworkSecurityGroups(com.microsoft.azure.management.network.NetworkSecurityGroups) ResourceGroups(com.microsoft.azure.management.resources.ResourceGroups) FrontendIPConfigurationInner(com.microsoft.azure.management.network.implementation.FrontendIPConfigurationInner) STANDARD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_LRS) DiskEncryptionSetIdentityType(com.microsoft.azure.management.compute.DiskEncryptionSetIdentityType) DeploymentOperations(com.microsoft.azure.management.resources.DeploymentOperations) URI(java.net.URI) Vault(com.microsoft.azure.management.keyvault.Vault) ResourceStatus(com.sequenceiq.cloudbreak.cloud.model.ResourceStatus) AvailabilitySet(com.microsoft.azure.management.compute.AvailabilitySet) LoadBalancerFrontend(com.microsoft.azure.management.network.LoadBalancerFrontend) Collection(java.util.Collection) com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) AzureDiskType(com.sequenceiq.cloudbreak.cloud.azure.AzureDiskType) Collectors(java.util.stream.Collectors) DiskStorageAccountTypes(com.microsoft.azure.management.compute.DiskStorageAccountTypes) Objects(java.util.Objects) AgreementTerms(com.microsoft.azure.management.marketplaceordering.v2015_06_01.AgreementTerms) List(java.util.List) VirtualNetworkLinkState(com.microsoft.azure.management.privatedns.v2018_09_01.VirtualNetworkLinkState) IndexableRefreshableWrapperImpl(com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableRefreshableWrapperImpl) NetworkInterfaces(com.microsoft.azure.management.network.NetworkInterfaces) CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) Optional(java.util.Optional) VirtualMachineCustomImage(com.microsoft.azure.management.compute.VirtualMachineCustomImage) AccessPolicy(com.microsoft.azure.management.keyvault.AccessPolicy) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) HasId(com.microsoft.azure.management.resources.fluentcore.arm.models.HasId) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) VirtualMachineInstanceView(com.microsoft.azure.management.compute.VirtualMachineInstanceView) Subnet(com.microsoft.azure.management.network.Subnet) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Kind(com.microsoft.azure.management.storage.Kind) Observable(rx.Observable) HashSet(java.util.HashSet) Network(com.microsoft.azure.management.network.Network) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) VirtualNetworkLinkInner(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner) PREMIUM_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.PREMIUM_LRS) PagedList(com.microsoft.azure.PagedList) DiskEncryptionSetType(com.microsoft.azure.management.compute.DiskEncryptionSetType) KeyPermissions(com.microsoft.azure.management.keyvault.KeyPermissions) AccessPolicyEntry(com.microsoft.azure.management.keyvault.AccessPolicyEntry) Collections.emptyMap(java.util.Collections.emptyMap) Deployment(com.microsoft.azure.management.resources.Deployment) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) DiskSkuTypes(com.microsoft.azure.management.compute.DiskSkuTypes) StorageAccountKey(com.microsoft.azure.management.storage.StorageAccountKey) KeyForDiskEncryptionSet(com.microsoft.azure.management.compute.KeyForDiskEncryptionSet) ULTRA_SSD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.ULTRA_SSD_LRS) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) CloudException(com.microsoft.azure.CloudException) STANDARD_SSD_LRS(com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_SSD_LRS) RoleAssignment(com.microsoft.azure.management.graphrbac.RoleAssignment) StorageAccountInner(com.microsoft.azure.management.storage.implementation.StorageAccountInner) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SUCCEEDED(com.microsoft.azure.management.privatedns.v2018_09_01.ProvisioningState.SUCCEEDED) Collections(java.util.Collections) DiskEncryptionSetInner(com.microsoft.azure.management.compute.implementation.DiskEncryptionSetInner) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)

Example 3 with PrivateZone

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

the class AzureClient method getPrivateDnsZonesByResourceGroup.

public PagedList<PrivateZone> getPrivateDnsZonesByResourceGroup(String subscriptionId, String resourceGroupName) {
    privatednsManager dnsManager = azureClientCredentials.getPrivateDnsManagerWithAnotherSubscription(subscriptionId);
    PagedList<PrivateZone> privateDnsZones = dnsManager.privateZones().listByResourceGroup(resourceGroupName);
    privateDnsZones.loadAll();
    return privateDnsZones;
}
Also used : com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager(com.microsoft.azure.management.privatedns.v2018_09_01.implementation.privatednsManager) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)

Example 4 with PrivateZone

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

the class AzureNewPrivateDnsZoneValidatorService method zonesNotConnectedToNetwork.

public ValidationResult.ValidationResultBuilder zonesNotConnectedToNetwork(AzureClient azureClient, String networkId, String singleResourceGroupName, Set<AzurePrivateDnsZoneServiceEnum> servicesWithExistingDnsZones, ValidationResult.ValidationResultBuilder resultBuilder) {
    List<AzurePrivateDnsZoneServiceEnum> cdpManagedPrivateEndpointServices = azurePrivateEndpointServicesProvider.getCdpManagedDnsZones(servicesWithExistingDnsZones);
    if (cdpManagedPrivateEndpointServices.isEmpty()) {
        LOGGER.debug("There are no private DNS zone services that CDP would manage on its own, skipping checking if DNS zones are already connected " + "to the network");
        return resultBuilder;
    }
    PagedList<PrivateZone> privateDnsZoneList = azureClient.getPrivateDnsZoneList();
    for (AzurePrivateDnsZoneServiceEnum service : cdpManagedPrivateEndpointServices) {
        LOGGER.debug("Validating network that no private DNS zone with name {} is connected to it.", service.getDnsZoneName());
        azurePrivateDnsZoneValidatorService.privateDnsZonesNotConnectedToNetwork(azureClient, networkId, singleResourceGroupName, service.getDnsZoneName(), resultBuilder, privateDnsZoneList);
    }
    return resultBuilder;
}
Also used : AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)

Example 5 with PrivateZone

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

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