use of com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork 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());
}
}
Aggregations