Search in sources :

Example 1 with NetworkResourcesCreationRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest in project cloudbreak by hortonworks.

the class EnvironmentNetworkService method createProviderSpecificNetworkResources.

public void createProviderSpecificNetworkResources(EnvironmentDto environment, BaseNetwork baseNetwork) {
    NetworkConnector networkConnector = getNetworkConnector(environment.getCloudPlatform());
    NetworkResourcesCreationRequest networkResourcesCreationRequest = networkCreationRequestFactory.createProviderSpecificNetworkResources(environment, baseNetwork);
    networkConnector.createProviderSpecificNetworkResources(networkResourcesCreationRequest);
}
Also used : NetworkConnector(com.sequenceiq.cloudbreak.cloud.NetworkConnector) NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)

Example 2 with NetworkResourcesCreationRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest in project cloudbreak by hortonworks.

the class NetworkCreationRequestFactory method createProviderSpecificNetworkResources.

public NetworkResourcesCreationRequest createProviderSpecificNetworkResources(EnvironmentDto environment, BaseNetwork baseNetwork) {
    NetworkDto networkDto = environment.getNetwork();
    NetworkResourcesCreationRequest.Builder builder = new NetworkResourcesCreationRequest.Builder().withNetworkId(NullUtil.getIfNotNull(baseNetwork, BaseNetwork::getNetworkId)).withNetworkResourceGroup(NullUtil.getIfNotNull(baseNetwork, this::getNetworkResourceGroupName)).withExistingNetwork(NullUtil.getIfNotNull(baseNetwork, this::isExistingNetwork)).withCloudCredential(getCredential(environment)).withCloudContext(getCloudContext(environment)).withRegion(Region.region(environment.getLocation().getName())).withPrivateEndpointsEnabled(ServiceEndpointCreation.ENABLED_PRIVATE_ENDPOINT == networkDto.getServiceEndpointCreation()).withServicesWithExistingPrivateDnsZones(azureExistingPrivateDnsZonesService.getServiceNamesWithExistingZones(networkDto)).withTags(environmentTagProvider.getTags(environment, environment.getNetwork().getResourceCrn()));
    getResourceGroupName(environment).ifPresent(builder::withResourceGroup);
    return builder.build();
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)

Example 3 with NetworkResourcesCreationRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest in project cloudbreak by hortonworks.

the class AzureNetworkConnectorTest method testCreateProviderSpecificNetworkResourcesWhenNotPrivateEndpoint.

@Test
public void testCreateProviderSpecificNetworkResourcesWhenNotPrivateEndpoint() {
    NetworkResourcesCreationRequest request = createProviderSpecificNetworkResources(false);
    underTest.createProviderSpecificNetworkResources(request);
    verify(azureClientService, never()).getClient(any());
    verify(azureDnsZoneService, never()).checkOrCreateDnsZones(any(), any(), any(), any(), any(), any());
    verify(azureNetworkLinkService, never()).checkOrCreateNetworkLinks(any(), any(), any(), any(), any(), any());
}
Also used : NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest) Test(org.junit.Test)

Example 4 with NetworkResourcesCreationRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest in project cloudbreak by hortonworks.

the class EnvironmentNetworkServiceTest method testCreateProviderSpecificNetworkResources.

@Test
void testCreateProviderSpecificNetworkResources() {
    EnvironmentDto environmentDto = EnvironmentDto.builder().withCloudPlatform(CLOUD_PLATFORM).withCreator(USER_CRN).build();
    NetworkResourcesCreationRequest networkResourcesCreationRequest = new NetworkResourcesCreationRequest.Builder().build();
    AzureEnvironmentNetworkConverter networkConverter = mock(AzureEnvironmentNetworkConverter.class);
    BaseNetwork baseNetwork = getNetwork();
    when(cloudConnector.networkConnector()).thenReturn(networkConnector);
    when(networkCreationRequestFactory.createProviderSpecificNetworkResources(environmentDto, baseNetwork)).thenReturn(networkResourcesCreationRequest);
    when(environmentNetworkConverterMap.get(CloudPlatform.valueOf(CLOUD_PLATFORM))).thenReturn(networkConverter);
    underTest.createProviderSpecificNetworkResources(environmentDto, baseNetwork);
    verify(cloudConnector).networkConnector();
    verify(cloudPlatformConnectors).get(any(CloudPlatformVariant.class));
    verify(networkCreationRequestFactory).createProviderSpecificNetworkResources(environmentDto, baseNetwork);
    verify(networkConnector).createProviderSpecificNetworkResources(networkResourcesCreationRequest);
}
Also used : BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) AzureEnvironmentNetworkConverter(com.sequenceiq.environment.network.v1.converter.AzureEnvironmentNetworkConverter) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with NetworkResourcesCreationRequest

use of com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest in project cloudbreak by hortonworks.

the class NetworkCreationRequestFactoryTest method testCreateProviderSpecificNetworkResourcesShouldCreateAProviderSpecificNetworkResourcesCreationRequestWhenResourceGroupNameIsPresent.

@ParameterizedTest
@EnumSource(ServiceEndpointCreation.class)
void testCreateProviderSpecificNetworkResourcesShouldCreateAProviderSpecificNetworkResourcesCreationRequestWhenResourceGroupNameIsPresent(ServiceEndpointCreation serviceEndpointCreation) {
    EnvironmentDto environmentDto = createAzureParametersDto(serviceEndpointCreation).build();
    CloudCredential cloudCredential = new CloudCredential("1", "asd", "account");
    BaseNetwork baseNetwork = getNetwork();
    when(credentialToCloudCredentialConverter.convert(environmentDto.getCredential())).thenReturn(cloudCredential);
    when(defaultSubnetCidrProvider.provide(NETWORK_CIDR, false)).thenReturn(cidrs(SUBNET_CIDRS, new HashSet<>()));
    NetworkResourcesCreationRequest request = underTest.createProviderSpecificNetworkResources(environmentDto, baseNetwork);
    assertEquals(NETWORK_ID, Long.parseLong(request.getNetworkId()));
    assertEquals(LEGACY_RG, request.getNetworkResourceGroup());
    assertEquals(cloudCredential, request.getCloudCredential());
    assertEquals(REGION, request.getRegion().getRegionName());
    assertEquals(SINGLE_RG, request.getResourceGroup());
    assertEquals(serviceEndpointCreation == ServiceEndpointCreation.ENABLED_PRIVATE_ENDPOINT, request.isPrivateEndpointsEnabled());
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) NetworkResourcesCreationRequest(com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest) HashSet(java.util.HashSet) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

NetworkResourcesCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkResourcesCreationRequest)7 Test (org.junit.Test)3 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 NetworkConnector (com.sequenceiq.cloudbreak.cloud.NetworkConnector)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 AzureEnvironmentNetworkConverter (com.sequenceiq.environment.network.v1.converter.AzureEnvironmentNetworkConverter)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1