use of com.sequenceiq.cloudbreak.domain.stack.instance.network.InstanceGroupNetwork 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.domain.stack.instance.network.InstanceGroupNetwork in project cloudbreak by hortonworks.
the class MultiAzValidator method collectSubnetIds.
public Set<String> collectSubnetIds(Iterable<InstanceGroup> instanceGroups) {
Set<String> allSubnetIds = new HashSet<>();
for (InstanceGroup instanceGroup : instanceGroups) {
InstanceGroupNetwork instanceGroupNetwork = instanceGroup.getInstanceGroupNetwork();
if (instanceGroupNetwork != null) {
Json attributes = instanceGroupNetwork.getAttributes();
if (attributes != null) {
List<String> subnetIds = (List<String>) attributes.getMap().getOrDefault(NetworkConstants.SUBNET_IDS, new ArrayList<>());
allSubnetIds.addAll(subnetIds);
}
}
}
return allSubnetIds;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.network.InstanceGroupNetwork in project cloudbreak by hortonworks.
the class InstanceGroupV4RequestToInstanceGroupConverterTest method testConvert.
@Test
public void testConvert() {
InstanceGroupV4Request request = getRequest("instance-group.json");
// GIVEN
given(providerParameterCalculator.get(request)).willReturn(getMappable());
given(instanceTemplateV4RequestToTemplateConverter.convert(any(InstanceTemplateV4Request.class))).willReturn(new Template());
given(securityGroupV4RequestToSecurityGroupConverter.convert(any(SecurityGroupV4Request.class))).willReturn(new SecurityGroup());
given(instanceGroupNetworkV4RequestToInstanceGroupNetworkConverter.convert(any(InstanceGroupNetworkV4Request.class))).willReturn(new InstanceGroupNetwork());
// WHEN
InstanceGroup instanceGroup = underTest.convert(request, "variant");
// THEN
assertAllFieldsNotNull(instanceGroup, List.of("stack", "targetGroups"));
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.network.InstanceGroupNetwork in project cloudbreak by hortonworks.
the class InstanceGroupNetworkV4RequestToInstanceGroupNetworkConverter method convert.
public InstanceGroupNetwork convert(InstanceGroupNetworkV4Request source) {
InstanceGroupNetwork network = new InstanceGroupNetwork();
CloudPlatform cloudPlatform = providerParameterCalculator.get(source).getCloudPlatform();
network.setCloudPlatform(cloudPlatform.name());
Map<String, Object> parameters = providerParameterCalculator.get(source).asMap();
Optional.ofNullable(parameters).map(toJson()).ifPresent(network::setAttributes);
return network;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.network.InstanceGroupNetwork in project cloudbreak by hortonworks.
the class InstanceGroupV4RequestToInstanceGroupConverter method setNetwork.
private void setNetwork(InstanceGroupV4Request source, InstanceGroup instanceGroup) {
if (source.getNetwork() != null) {
source.getNetwork().setCloudPlatform(source.getCloudPlatform());
InstanceGroupNetwork instanceGroupNetwork = instanceGroupNetworkV4RequestToInstanceGroupNetworkConverter.convert(source.getNetwork());
instanceGroup.setInstanceGroupNetwork(instanceGroupNetwork);
}
}
Aggregations