Search in sources :

Example 1 with NetworkRequest

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;
}
Also used : CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) InstanceGroupNetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

Example 2 with NetworkRequest

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);
}
Also used : NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) AwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceGroupNetwork(com.sequenceiq.freeipa.entity.InstanceGroupNetwork) Test(org.junit.jupiter.api.Test)

Example 3 with NetworkRequest

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;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) InstanceGroupNetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) AwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters) InstanceGroupAwsNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.aws.InstanceGroupAwsNetworkParameters) AwsParams(com.sequenceiq.environment.network.dto.AwsParams)

Example 4 with 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;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) AzureNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

Example 5 with 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;
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) GcpParams(com.sequenceiq.environment.network.dto.GcpParams) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) GcpNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.GcpNetworkParameters)

Aggregations

NetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)21 Test (org.junit.jupiter.api.Test)11 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)10 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)10 Stack (com.sequenceiq.freeipa.entity.Stack)10 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)9 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 Template (com.sequenceiq.freeipa.entity.Template)9 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)8 Json (com.sequenceiq.cloudbreak.common.json.Json)6 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)6 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)4 AwsNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AwsNetworkParameters)4 HashMap (java.util.HashMap)4 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)3 InstanceGroupNetworkRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest)3 AzureNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters)3 MockNetworkParameters (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters)3 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2