use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getNetworkRequest.
private NetworkRequest getNetworkRequest(Network network) {
NetworkRequest request = null;
if (network != null) {
request = new NetworkRequest();
Optional<CloudPlatform> cloudPlatform = Optional.ofNullable(network.cloudPlatform()).or(() -> Optional.ofNullable(network.getAttributes().getValue(NetworkConstants.CLOUD_PLATFORM))).map(CloudPlatform::valueOf);
request.setNetworkCidrs(network.getNetworkCidrs());
request.setOutboundInternetTraffic(network.getOutboundInternetTraffic());
if (cloudPlatform.isPresent()) {
LOGGER.debug("Network request has cloud platform {}", cloudPlatform.get());
request.setCloudPlatform(cloudPlatform.get());
switch(cloudPlatform.get()) {
case AWS:
request.createAws().parse(network.getAttributes().getMap());
break;
case AZURE:
request.createAzure().parse(network.getAttributes().getMap());
break;
case GCP:
request.createGcp().parse(network.getAttributes().getMap());
break;
case MOCK:
request.createMock().parse(network.getAttributes().getMap());
break;
case YARN:
request.createYarn().parse(network.getAttributes().getMap());
break;
default:
break;
}
}
}
LOGGER.debug("Created network request {} from network {}", request, network);
return request;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.
the class DefaultInstanceGroupProviderTest method createDefaultNetworkWithAwsAttributesShouldReturnWithNetworkAttributes.
@Test
void createDefaultNetworkWithAwsAttributesShouldReturnWithNetworkAttributes() {
Json json = new Json(Map.of(NetworkConstants.SUBNET_IDS, Set.of("id")));
NetworkRequest network = new NetworkRequest();
AwsNetworkParameters awsNetworkParameters = new AwsNetworkParameters();
awsNetworkParameters.setSubnetId("id");
network.setAws(awsNetworkParameters);
InstanceGroupNetwork defaultNetwork = underTest.createDefaultNetwork(CloudPlatform.AWS, network);
assertThat(defaultNetwork.getAttributes()).isEqualTo(json);
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.
the class FreeIpaAwsNetworkProvider method network.
@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
NetworkDto network = environment.getNetwork();
NetworkRequest networkRequest = new NetworkRequest();
AwsParams awsParams = network.getAws();
AwsNetworkParameters awsNetworkParameters = new AwsNetworkParameters();
networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
networkRequest.setOutboundInternetTraffic(network.getOutboundInternetTraffic());
awsNetworkParameters.setVpcId(awsParams.getVpcId());
if (!multiAzRequired) {
ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), CloudPlatform.AWS, multiAzRequired);
awsNetworkParameters.setSubnetId(providedSubnetIds.getSubnetId());
}
networkRequest.setAws(awsNetworkParameters);
return networkRequest;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.
the class FreeIpaAzureNetworkProvider method network.
@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
NetworkRequest networkRequest = new NetworkRequest();
NetworkDto network = environment.getNetwork();
AzureParams azureParams = network.getAzure();
AzureNetworkParameters azureNetworkParameters = new AzureNetworkParameters();
azureNetworkParameters.setNetworkId(azureParams.getNetworkId());
azureNetworkParameters.setNoPublicIp(azureParams.isNoPublicIp());
azureNetworkParameters.setResourceGroupName(azureParams.getResourceGroupName());
ProvidedSubnetIds providedSubnetIds = subnetIdProvider.subnets(network, environment.getExperimentalFeatures().getTunnel(), CloudPlatform.AZURE, multiAzRequired);
azureNetworkParameters.setSubnetId(providedSubnetIds.getSubnetId());
networkRequest.setAzure(azureNetworkParameters);
networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
return networkRequest;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.
the class FreeIpaGcpNetworkProvider method network.
@Override
public NetworkRequest network(EnvironmentDto environment, boolean multiAzRequired) {
NetworkRequest networkRequest = new NetworkRequest();
NetworkDto network = environment.getNetwork();
GcpParams gcpParams = network.getGcp();
GcpNetworkParameters gcpNetworkParameters = new GcpNetworkParameters();
gcpNetworkParameters.setNetworkId(gcpParams.getNetworkId());
gcpNetworkParameters.setNoFirewallRules(gcpParams.getNoFirewallRules());
gcpNetworkParameters.setNoPublicIp(gcpParams.getNoPublicIp());
gcpNetworkParameters.setSharedProjectId(gcpParams.getSharedProjectId());
gcpNetworkParameters.setSubnetId(network.getSubnetIds().iterator().next());
networkRequest.setGcp(gcpNetworkParameters);
networkRequest.setNetworkCidrs(collectNetworkCidrs(network));
return networkRequest;
}
Aggregations