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