use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkConverter method setCreatedCloudNetwork.
@Override
public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) {
AwsNetwork awsNetwork = (AwsNetwork) baseNetwork;
awsNetwork.setName(createdCloudNetwork.getStackName());
awsNetwork.setVpcId(createdCloudNetwork.getNetworkId());
awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream().collect(Collectors.toMap(CreatedSubnet::getSubnetId, subnet -> new CloudSubnet(subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()))));
return awsNetwork;
}
use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet in project cloudbreak by hortonworks.
the class MockEnvironmentNetworkConverter method setCreatedCloudNetwork.
@Override
public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) {
MockNetwork mockNetwork = (MockNetwork) baseNetwork;
mockNetwork.setName(createdCloudNetwork.getStackName());
mockNetwork.setVpcId(createdCloudNetwork.getNetworkId());
mockNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream().collect(Collectors.toMap(CreatedSubnet::getSubnetId, subnet -> new CloudSubnet(subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()))));
return mockNetwork;
}
use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet in project cloudbreak by hortonworks.
the class GcpNetworkConnector method createNetworkWithSubnets.
@Override
public CreatedCloudNetwork createNetworkWithSubnets(NetworkCreationRequest networkCreationRequest) {
CloudContext cloudContext = getCloudContext(networkCreationRequest);
AuthenticatedContext auth = new AuthenticatedContext(cloudContext, networkCreationRequest.getCloudCredential());
Network network = buildNetworkForCreation(networkCreationRequest);
GcpContext context = contextBuilders.contextInit(cloudContext, auth, network, null, true);
try {
CloudResource networkResource = createNetwork(context, auth, network);
List<CreatedSubnet> subnetList = getCloudSubNets(networkCreationRequest);
for (CreatedSubnet createdSubnet : subnetList) {
createSubnet(context, auth, buildSubnetForCreation(networkCreationRequest, createdSubnet.getCidr()), createdSubnet);
}
return new CreatedCloudNetwork(networkCreationRequest.getEnvName(), networkResource.getName(), getCreatedSubnets(subnetList));
} catch (TokenResponseException e) {
throw gcpStackUtil.getMissingServiceAccountKeyError(e, context.getProjectId());
} catch (GoogleJsonResponseException e) {
throw new GcpResourceException(checkException(e), GCP_NETWORK, networkCreationRequest.getEnvName());
} catch (IOException e) {
throw new GcpResourceException("Network creation failed due to IO exception", GCP_NETWORK, networkCreationRequest.getEnvName());
}
}
use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet in project cloudbreak by hortonworks.
the class GcpNetworkConnector method getCreatedSubnets.
private Set<CreatedSubnet> getCreatedSubnets(List<CreatedSubnet> createdSubnetList) {
Set<CreatedSubnet> subnets = new HashSet<>();
for (int i = 0; i < createdSubnetList.size(); i++) {
CreatedSubnet createdSubnetIndexed = createdSubnetList.get(i);
CreatedSubnet createdSubnet = new CreatedSubnet();
createdSubnet.setSubnetId(createdSubnetIndexed.getSubnetId());
createdSubnet.setCidr(createdSubnetList.get(i).getCidr());
createdSubnet.setAvailabilityZone(createdSubnetList.get(i).getAvailabilityZone());
createdSubnet.setMapPublicIpOnLaunch(true);
createdSubnet.setIgwAvailable(true);
subnets.add(createdSubnet);
}
return subnets;
}
use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet in project cloudbreak by hortonworks.
the class AwsCreatedSubnetProvider method provide.
Set<CreatedSubnet> provide(Map<String, String> output, List<SubnetRequest> subnetRequests, boolean privateSubnetEnabled) {
Set<CreatedSubnet> subnets = new HashSet<>();
for (SubnetRequest subnetRequest : subnetRequests) {
CreatedSubnet createdPublicSubnet = new CreatedSubnet();
createdPublicSubnet.setSubnetId(getValue(output, "id" + subnetRequest.getIndex()));
createdPublicSubnet.setAvailabilityZone(subnetRequest.getAvailabilityZone());
if (!Strings.isNullOrEmpty(subnetRequest.getPrivateSubnetCidr()) && privateSubnetEnabled) {
createdPublicSubnet.setCidr(subnetRequest.getPrivateSubnetCidr());
createdPublicSubnet.setPublicSubnet(false);
createdPublicSubnet.setMapPublicIpOnLaunch(false);
createdPublicSubnet.setIgwAvailable(false);
} else {
createdPublicSubnet.setCidr(subnetRequest.getPublicSubnetCidr());
createdPublicSubnet.setPublicSubnet(true);
createdPublicSubnet.setMapPublicIpOnLaunch(true);
createdPublicSubnet.setIgwAvailable(true);
}
createdPublicSubnet.setType(subnetRequest.getType());
subnets.add(createdPublicSubnet);
}
return subnets;
}
Aggregations