use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.
the class AzureSubnetSelectorServiceTest method testselectWhenNotDatabaseTwoSubnetsThenOneIsSelected.
@Test
public void testselectWhenNotDatabaseTwoSubnetsThenOneIsSelected() {
List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet().withPrivateSubnet().build();
SubnetSelectionResult subnetSelectionResult = underTest.select(subnets, SubnetSelectionParameters.builder().build());
assertEquals(2, subnetSelectionResult.getResult().size());
}
use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.
the class AzureSubnetSelectorServiceTest method testSelectWhenParametersNullThenReturnsError.
@Test
public void testSelectWhenParametersNullThenReturnsError() {
List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet().build();
SubnetSelectionResult subnetSelectionResult = underTest.select(subnets, null);
assertTrue(subnetSelectionResult.hasError());
assertEquals("Azure subnet selection: parameters were not specified.", subnetSelectionResult.getErrorMessage());
}
use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.
the class AzureSubnetSelectorServiceTest method testselectWhenDatabaseThreeSubnetsThenAllAreReturned.
@Test
public void testselectWhenDatabaseThreeSubnetsThenAllAreReturned() {
List<CloudSubnet> subnets = new SubnetBuilder().withPrivateSubnet().withPrivateSubnet().withPrivateSubnet().build();
SubnetSelectionResult subnetSelectionResult = underTest.select(subnets, SubnetSelectionParameters.builder().withPreferPrivateIfExist().build());
assertEquals(3, subnetSelectionResult.getResult().size());
List<String> selectedSubnetIds = subnetSelectionResult.getResult().stream().map(CloudSubnet::getId).collect(Collectors.toList());
assertThat(selectedSubnetIds, hasItem("subnet-1"));
assertThat(selectedSubnetIds, hasItem("subnet-2"));
assertThat(selectedSubnetIds, hasItem("subnet-3"));
}
use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.
the class AzureSubnetSelectorServiceTest method testSelectWhenNoSubnetsThenReturnsError.
@Test
public void testSelectWhenNoSubnetsThenReturnsError() {
List<CloudSubnet> subnets = new SubnetBuilder().build();
SubnetSelectionResult subnetSelectionResult = underTest.select(subnets, SubnetSelectionParameters.builder().build());
assertTrue(subnetSelectionResult.hasError());
assertEquals("Azure subnet selection: there are no subnets to choose from.", subnetSelectionResult.getErrorMessage());
}
use of com.sequenceiq.cloudbreak.cloud.model.SubnetSelectionResult in project cloudbreak by hortonworks.
the class AzureSubnetSelectorService method selectForPrivateEndpoint.
public SubnetSelectionResult selectForPrivateEndpoint(Collection<CloudSubnet> subnetMetas, boolean existingNetwork) {
List<CloudSubnet> suitableCloudSubnet;
if (existingNetwork) {
LOGGER.debug("Selecting subnets for private endpoint, existing network");
suitableCloudSubnet = subnetMetas.stream().filter(sn -> azureCloudSubnetParametersService.isPrivateEndpointNetworkPoliciesDisabled(sn)).collect(Collectors.toList());
} else {
LOGGER.debug("Selecting subnets for private endpoint, new network - all subnets are suitable");
suitableCloudSubnet = new ArrayList<>(subnetMetas);
}
return suitableCloudSubnet.isEmpty() ? new SubnetSelectionResult("No suitable subnets found for placing a private endpoint " + "because of the network policy being enabled, please disable network policies for private endpoints and try again!") : new SubnetSelectionResult(suitableCloudSubnet);
}
Aggregations