use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverter method buildAzureConfig.
private TargetGroupConfigDbWrapper buildAzureConfig(AzureLoadBalancerMetadataView azureMetadata, TargetGroup targetGroup) {
Set<Integer> trafficPorts = getTrafficPorts(targetGroup);
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
AzureTargetGroupConfigDb azureTargetGroupConfigDb = new AzureTargetGroupConfigDb();
for (Integer port : trafficPorts) {
String availabilitySetName = azureMetadata.getAvailabilitySetByPort(port);
List<String> availabilitySetNames = List.of(StringUtils.isEmpty(availabilitySetName) ? MISSING_CLOUD_RESOURCE : availabilitySetName);
azureTargetGroupConfigDb.addPortAvailabilitySetMapping(port, availabilitySetNames);
}
targetGroupConfigDbWrapper.setAzureConfig(azureTargetGroupConfigDb);
return targetGroupConfigDbWrapper;
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroupMissingAvailabilitySetInMetadata.
@Test
public void testConvertAzureTargetGroupMissingAvailabilitySetInMetadata() {
Map<String, Object> azureParams = createAzureParams(1);
azureParams.put(AzureLoadBalancerMetadataView.getAvailabilitySetParam(PORT2), null);
CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(azureParams).build();
TargetGroup targetGroup = new TargetGroup();
targetGroup.setType(TargetGroupType.KNOX);
TargetGroupPortPair portPair1 = new TargetGroupPortPair(PORT1, PORT2);
TargetGroupPortPair portPair2 = new TargetGroupPortPair(PORT2, PORT2);
TargetGroupPortPair portPair3 = new TargetGroupPortPair(PORT3, PORT3);
when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair1, portPair2, portPair3));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
assertEquals(Set.of(PORT1, PORT2, PORT3), azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet());
List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
assertEquals(List.of(AVAILABILITY_SET_NAME), availabilitySets);
availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT2);
assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT3);
assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroup.
@Test
public void testConvertAzureTargetGroup() {
CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAzureParams(1)).build();
TargetGroup targetGroup = new TargetGroup();
targetGroup.setType(TargetGroupType.KNOX);
TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
assertEquals(1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().size());
assertEquals(PORT1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet().iterator().next());
List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
assertEquals(1, availabilitySets.size());
assertEquals(AVAILABILITY_SET_NAME, availabilitySets.get(0));
}
use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method createAzureTargetGroups.
private Set<TargetGroup> createAzureTargetGroups() {
AzureTargetGroupConfigDb azureTargetGroupConfigDb = new AzureTargetGroupConfigDb();
azureTargetGroupConfigDb.setPortAvailabilitySetMapping(Map.of(PORT, List.of(AZURE_AS_NAME)));
TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
targetGroupConfigDbWrapper.setAzureConfig(azureTargetGroupConfigDb);
TargetGroup targetGroup = new TargetGroup();
targetGroup.setProviderConfig(targetGroupConfigDbWrapper);
return Set.of(targetGroup);
}
Aggregations