use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request in project cloudbreak by hortonworks.
the class NetworkToNetworkV4RequestConverterTest method testConvertWhenSubnetCidrIsNotNullThenResultShouldContainSubnetCidr.
@Test
void testConvertWhenSubnetCidrIsNotNullThenResultShouldContainSubnetCidr() {
Network input = new Network();
input.setSubnetCIDR("someCidr");
NetworkV4Request result = underTest.convert(input);
assertNotNull(result);
assertEquals(input.getSubnetCIDR(), result.getSubnetCIDR());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverter method convert.
public StackV4Request convert(DistroXV1Request source) {
DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(source.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
StackV4Request request = new StackV4Request();
SdxClusterResponse sdxClusterResponse = getSdxClusterResponse(environment);
request.setName(source.getName());
request.setType(StackType.WORKLOAD);
request.setCloudPlatform(getCloudPlatform(environment));
request.setEnvironmentCrn(environment.getCrn());
request.setAuthentication(getIfNotNull(environment.getAuthentication(), authenticationConverter::convert));
request.setImage(getIfNotNull(source.getImage(), imageConverter::convert));
request.setCluster(getIfNotNull(source, environment, clusterConverter::convert));
NetworkV4Request network = getNetwork(source.getNetwork(), environment, source.getInstanceGroups());
request.setNetwork(network);
request.setInstanceGroups(getIfNotNull(source.getInstanceGroups(), igs -> instanceGroupConverter.convertTo(network, igs, environment)));
request.setAws(getIfNotNull(source.getAws(), stackParameterConverter::convert));
request.setAzure(getIfNotNull(source.getAzure(), stackParameterConverter::convert));
request.setGcp(getIfNotNull(source.getGcp(), stackParameterConverter::convert));
request.setYarn(getYarnProperties(source, environment));
request.setInputs(source.getInputs());
request.setTags(getIfNotNull(source.getTags(), this::getTags));
request.setPlacement(preparePlacement(environment));
request.setSharedService(sdxConverter.getSharedService(sdxClusterResponse));
request.setCustomDomain(null);
request.setTimeToLive(source.getTimeToLive());
request.setTelemetry(getTelemetryRequest(environment, sdxClusterResponse));
request.setGatewayPort(source.getGatewayPort());
request.setExternalDatabase(getIfNotNull(source.getExternalDatabase(), databaseRequestConverter::convert));
request.setEnableLoadBalancer(source.isEnableLoadBalancer());
request.setVariant(source.getVariant());
checkMultipleGatewayNodes(source);
return request;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request in project cloudbreak by hortonworks.
the class InstanceGroupV1ToInstanceGroupV4Converter method convert.
private InstanceGroupV4Request convert(NetworkV4Request network, InstanceGroupV1Request source, DetailedEnvironmentResponse environment) {
InstanceGroupV4Request response = new InstanceGroupV4Request();
response.setNodeCount(source.getNodeCount());
response.setType(source.getType());
response.setCloudPlatform(source.getCloudPlatform());
response.setName(source.getName());
response.setTemplate(getIfNotNull(source.getTemplate(), environment, instanceTemplateConverter::convert));
response.setRecoveryMode(source.getRecoveryMode());
response.setScalabilityOption(source.getScalabilityOption());
response.setSecurityGroup(createSecurityGroupFromEnvironment(source.getType(), environment));
response.setRecipeNames(source.getRecipeNames());
response.setMinimumNodeCount(source.getMinimumNodeCount());
response.setAws(getIfNotNull(source.getAws(), instanceGroupParameterConverter::convert));
response.setAzure(getIfNotNull(source.getAzure(), instanceGroupParameterConverter::convert));
response.setGcp(getIfNotNull(source.getGcp(), instanceGroupParameterConverter::convert));
response.setYarn(getIfNotNull(source.getYarn(), instanceGroupParameterConverter::convert));
response.setNetwork(getInstanceGroupNetworkV4Request(network, source, environment));
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenHasSameSubnetIdInInstanceGroupsNetworkAws.
@Test
public void testGetNetworkWhenHasSameSubnetIdInInstanceGroupsNetworkAws() {
NetworkV1Request networkRequest = new NetworkV1Request();
AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
aws.setSubnetId("sub1");
networkRequest.setAws(aws);
Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters = new InstanceGroupAwsNetworkV1Parameters();
awsNetworkV1Parameters.setSubnetIds(List.of("subnet1"));
network.setAws(awsNetworkV1Parameters);
ig1.setNetwork(network);
InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters1 = new InstanceGroupAwsNetworkV1Parameters();
awsNetworkV1Parameters1.setSubnetIds(List.of("subnet1"));
network1.setAws(awsNetworkV1Parameters1);
ig2.setNetwork(network1);
instanceGroups.add(ig1);
instanceGroups.add(ig2);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("ANY");
NetworkV4Request networkV4Request = new NetworkV4Request();
ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
Assertions.assertEquals(networkV4Request, actual);
Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
Assertions.assertEquals("subnet1", captured.getKey().getAws().getSubnetId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testGetNetworkWhenSubnetIdsIsNullInInstanceGroupsNetworkAws.
@Test
public void testGetNetworkWhenSubnetIdsIsNullInInstanceGroupsNetworkAws() {
NetworkV1Request networkRequest = new NetworkV1Request();
AwsNetworkV1Parameters aws = new AwsNetworkV1Parameters();
aws.setSubnetId("sub1");
networkRequest.setAws(aws);
Set<InstanceGroupV1Request> instanceGroups = new HashSet<>();
InstanceGroupV1Request ig1 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network = new InstanceGroupNetworkV1Request();
network.setAws(new InstanceGroupAwsNetworkV1Parameters());
ig1.setNetwork(network);
InstanceGroupV1Request ig2 = new InstanceGroupV1Request();
InstanceGroupNetworkV1Request network1 = new InstanceGroupNetworkV1Request();
network1.setAws(new InstanceGroupAwsNetworkV1Parameters());
ig2.setNetwork(network1);
instanceGroups.add(ig1);
instanceGroups.add(ig2);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("ANY");
NetworkV4Request networkV4Request = new NetworkV4Request();
ArgumentCaptor<Pair<NetworkV1Request, DetailedEnvironmentResponse>> networkConverterCaptor = ArgumentCaptor.forClass(Pair.class);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(networkV4Request);
NetworkV4Request actual = underTest.getNetwork(networkRequest, environment, instanceGroups);
verify(networkConverter).convertToNetworkV4Request(networkConverterCaptor.capture());
Assertions.assertEquals(networkV4Request, actual);
Pair<NetworkV1Request, DetailedEnvironmentResponse> captured = networkConverterCaptor.getValue();
Assertions.assertEquals("sub1", captured.getKey().getAws().getSubnetId());
}
Aggregations