use of com.sequenceiq.cloudbreak.cloud.model.GroupNetwork in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method buildGroupNetwork.
private GroupNetwork buildGroupNetwork(com.sequenceiq.freeipa.entity.Network network, InstanceGroup instanceGroup) {
GroupNetwork groupNetwork = null;
InstanceGroupNetwork instanceGroupNetwork = instanceGroup.getInstanceGroupNetwork();
if (instanceGroupNetwork != null) {
Json attributes = instanceGroupNetwork.getAttributes();
Map<String, Object> params = attributes == null ? Collections.emptyMap() : attributes.getMap();
Set<GroupSubnet> subnets = new HashSet<>();
if (params != null) {
List<String> subnetIds = (List<String>) params.getOrDefault(NetworkConstants.SUBNET_IDS, new ArrayList<>());
for (String subnetId : subnetIds) {
GroupSubnet groupSubnet = new GroupSubnet(subnetId);
subnets.add(groupSubnet);
}
}
groupNetwork = new GroupNetwork(network.getOutboundInternetTraffic(), subnets, params);
}
return groupNetwork;
}
use of com.sequenceiq.cloudbreak.cloud.model.GroupNetwork in project cloudbreak by hortonworks.
the class AwsGatewaySubnetMultiAzValidatorTest method testValidateWhenThereIsGatewayGroupButInstanceGroupNetworkHasConfigurationWithMultipleSubnetPerAvailabilityZone.
@Test
void testValidateWhenThereIsGatewayGroupButInstanceGroupNetworkHasConfigurationWithMultipleSubnetPerAvailabilityZone() {
String aSubnetId = "aSubnetId";
String availabilityZone = "anAZ";
Set<GroupSubnet> of = Set.of(new GroupSubnet(aSubnetId));
GroupNetwork groupNetwork = new GroupNetwork(OutboundInternetTraffic.ENABLED, of, Map.of());
Group gatewayGroup = getGroup("aGroupName", InstanceGroupType.GATEWAY, groupNetwork);
CloudStack cloudStack = getCloudStack(Set.of(gatewayGroup));
when(awsClient.createEc2Client(any(), any())).thenReturn(ec2Client);
Set<Subnet> subnets = Set.of(new Subnet().withSubnetId(aSubnetId).withAvailabilityZone(availabilityZone), new Subnet().withSubnetId("anotherSubnetId").withAvailabilityZone(availabilityZone));
DescribeSubnetsResult describeSubnetsResult = new DescribeSubnetsResult().withSubnets(subnets);
when(ec2Client.describeSubnets(any())).thenReturn(describeSubnetsResult);
Assertions.assertThrows(CloudConnectorException.class, () -> underTest.validate(authenticatedContext, cloudStack));
}
use of com.sequenceiq.cloudbreak.cloud.model.GroupNetwork in project cloudbreak by hortonworks.
the class AwsGatewaySubnetMultiAzValidator method getInstanceGroupNetworSubnetIds.
private Set<String> getInstanceGroupNetworSubnetIds(Group group) {
Set<String> result = new HashSet<>();
GroupNetwork network = group.getNetwork();
if (network != null) {
result = Optional.ofNullable(network.getSubnets()).orElse(new HashSet<>()).stream().map(GroupSubnet::getSubnetId).collect(Collectors.toSet());
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.GroupNetwork in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method buildGroupNetwork.
public GroupNetwork buildGroupNetwork(com.sequenceiq.cloudbreak.domain.Network stackNetwork, InstanceGroup instanceGroup) {
GroupNetwork groupNetwork = null;
InstanceGroupNetwork instanceGroupNetwork = instanceGroup.getInstanceGroupNetwork();
if (instanceGroupNetwork != null) {
Json attributes = instanceGroupNetwork.getAttributes();
Map<String, Object> params = attributes == null ? Collections.emptyMap() : attributes.getMap();
Set<GroupSubnet> subnets = new HashSet<>();
Set<GroupSubnet> endpointGatewaySubnets = new HashSet<>();
if (params != null) {
List<String> subnetIds = (List<String>) params.getOrDefault(NetworkConstants.SUBNET_IDS, new ArrayList<>());
for (String subnetId : subnetIds) {
GroupSubnet groupSubnet = new GroupSubnet(subnetId);
subnets.add(groupSubnet);
}
List<String> endpointGatewaySubnetIds = (List<String>) params.getOrDefault(NetworkConstants.ENDPOINT_GATEWAY_SUBNET_IDS, new ArrayList<>());
for (String endpointGatewaySubnetId : endpointGatewaySubnetIds) {
GroupSubnet groupSubnet = new GroupSubnet(endpointGatewaySubnetId);
endpointGatewaySubnets.add(groupSubnet);
}
}
groupNetwork = new GroupNetwork(getOutboundInternetTraffic(stackNetwork), subnets, endpointGatewaySubnets, params);
}
return groupNetwork;
}
use of com.sequenceiq.cloudbreak.cloud.model.GroupNetwork in project cloudbreak by hortonworks.
the class AwsGatewaySubnetMultiAzValidatorTest method testValidateWhenThereIsGatewayGroupButInstanceGroupNetworkDoesNotHaveSubnetsConfigured.
@Test
void testValidateWhenThereIsGatewayGroupButInstanceGroupNetworkDoesNotHaveSubnetsConfigured() {
GroupNetwork groupNetwork = new GroupNetwork(OutboundInternetTraffic.ENABLED, null, Map.of());
Group gatewayGroup = getGroup("aGroupName", InstanceGroupType.GATEWAY, groupNetwork);
CloudStack cloudStack = getCloudStack(Set.of(gatewayGroup));
underTest.validate(authenticatedContext, cloudStack);
}
Aggregations