Search in sources :

Example 6 with AzurePrivateDnsZoneServiceEnum

use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum 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 7 with AzurePrivateDnsZoneServiceEnum

use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.

the class AzureDnsZoneCreationCheckerTask method doCall.

@Override
protected Boolean doCall() {
    String deploymentName = context.getDeploymentName();
    String resourceGroupName = context.getResourceGroupName();
    AzureClient azureClient = context.getAzureClient();
    String networkId = context.getNetworkId();
    List<AzurePrivateDnsZoneServiceEnum> enabledPrivateEndpointServices = context.getEnabledPrivateEndpointServices();
    LOGGER.info("Waiting for DNS zone deployment to be created: {}", deploymentName);
    ResourceStatus templateDeploymentStatus = azureClient.getTemplateDeploymentStatus(resourceGroupName, deploymentName);
    if (templateDeploymentStatus == ResourceStatus.DELETED) {
        throw new CloudConnectorException(String.format("Deployment %s is either deleted or does not exist", deploymentName));
    }
    if (templateDeploymentStatus.isPermanent()) {
        LOGGER.info("Deployment has been finished with status {}", templateDeploymentStatus);
        if (StringUtils.isNotEmpty(networkId)) {
            return azureClient.checkIfNetworkLinksDeployed(resourceGroupName, networkId, enabledPrivateEndpointServices);
        } else {
            return azureClient.checkIfDnsZonesDeployed(resourceGroupName, enabledPrivateEndpointServices);
        }
    } else {
        LOGGER.info("DNS zone or network link creation not finished yet.");
        return false;
    }
}
Also used : AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) ResourceStatus(com.sequenceiq.cloudbreak.cloud.model.ResourceStatus) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)

Example 8 with AzurePrivateDnsZoneServiceEnum

use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.

the class AzureExistingPrivateDnsZoneValidatorServiceTest method testValidateWhenValidAndInvalidPrivateDnsZoneResourceId.

@Test
void testValidateWhenValidAndInvalidPrivateDnsZoneResourceId() {
    ValidationResult.ValidationResultBuilder resultBuilder = new ValidationResult.ValidationResultBuilder();
    ResourceId privateDnsZoneIdPostgres = getPrivateDnsZoneResourceId();
    String privateDnsZoneIdStorage = "invalidPrivateDnsZoneId";
    Map<AzurePrivateDnsZoneServiceEnum, String> serviceToPrivateDnsZoneId = Map.of(AzurePrivateDnsZoneServiceEnum.POSTGRES, privateDnsZoneIdPostgres.id(), AzurePrivateDnsZoneServiceEnum.STORAGE, privateDnsZoneIdStorage);
    when(azurePrivateDnsZoneValidatorService.existingPrivateDnsZoneNameIsSupported(any(), any(), any())).thenAnswer(invocation -> {
        ValidationResult.ValidationResultBuilder validationResultBuilder = invocation.getArgument(2);
        ResourceId privateDnsZoneId = invocation.getArgument(1);
        if (privateDnsZoneId.id().equals(privateDnsZoneIdStorage)) {
            throw new InvalidParameterException();
        }
        return validationResultBuilder;
    });
    resultBuilder = underTest.validate(azureClient, NETWORK_RESOURCE_GROUP_NAME, NETWORK_NAME, serviceToPrivateDnsZoneId, resultBuilder);
    ValidationTestUtil.checkErrorsPresent(resultBuilder, List.of("The provided private DNS zone id invalidPrivateDnsZoneId for service " + "Microsoft.Storage/storageAccounts is not a valid azure resource id."));
    verify(azurePrivateDnsZoneValidatorService).existingPrivateDnsZoneNameIsSupported(eq(AzurePrivateDnsZoneServiceEnum.POSTGRES), any(), eq(resultBuilder));
    verify(azurePrivateDnsZoneValidatorService).privateDnsZoneExists(eq(azureClient), any(), eq(resultBuilder));
    verify(azurePrivateDnsZoneValidatorService).privateDnsZoneConnectedToNetwork(eq(azureClient), eq(NETWORK_RESOURCE_GROUP_NAME), eq(NETWORK_NAME), any(), eq(resultBuilder));
    verify(azurePrivateDnsZoneValidatorService, never()).existingPrivateDnsZoneNameIsSupported(eq(AzurePrivateDnsZoneServiceEnum.STORAGE), any(), any());
}
Also used : InvalidParameterException(java.security.InvalidParameterException) PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId) ResourceId(com.microsoft.azure.arm.resources.ResourceId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) Test(org.junit.jupiter.api.Test)

Example 9 with AzurePrivateDnsZoneServiceEnum

use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.

the class AzureExistingPrivateDnsZonesServiceTest method testGetExistingZonesWhenPostgresPresent.

@Test
void testGetExistingZonesWhenPostgresPresent() {
    NetworkDto networkDto = getNetworkDto("postgresPrivateDnsZoneId");
    Map<AzurePrivateDnsZoneServiceEnum, String> existingZones = underTest.getExistingZones(networkDto);
    assertEquals("postgresPrivateDnsZoneId", existingZones.get(AzurePrivateDnsZoneServiceEnum.POSTGRES));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) Test(org.junit.jupiter.api.Test)

Example 10 with AzurePrivateDnsZoneServiceEnum

use of com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum in project cloudbreak by hortonworks.

the class AzureExistingPrivateDnsZonesServiceTest method testGetExistingZonesWhenPostgresNotPresent.

@Test
void testGetExistingZonesWhenPostgresNotPresent() {
    NetworkDto networkDto = getNetworkDto(null);
    Map<AzurePrivateDnsZoneServiceEnum, String> existingZones = underTest.getExistingZones(networkDto);
    assertThat(existingZones).isEmpty();
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) Test(org.junit.jupiter.api.Test)

Aggregations

AzurePrivateDnsZoneServiceEnum (com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)12 Test (org.junit.jupiter.api.Test)7 PrivateZone (com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)3 VirtualNetworkLinkInner (com.microsoft.azure.management.privatedns.v2018_09_01.implementation.VirtualNetworkLinkInner)3 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)3 ResourceStatus (com.sequenceiq.cloudbreak.cloud.model.ResourceStatus)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Strings (com.google.common.base.Strings)2 CloudException (com.microsoft.azure.CloudException)2 PagedList (com.microsoft.azure.PagedList)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 STANDARD_SSD_LRS (com.microsoft.azure.management.compute.DiskSkuTypes.STANDARD_SSD_LRS)2