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;
}
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;
}
}
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());
}
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));
}
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();
}
Aggregations