Search in sources :

Example 16 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverterTest method testConvertForInstanceGroupsWhenAwsNativeIsPresent.

@Test
void testConvertForInstanceGroupsWhenAwsNativeIsPresent() {
    CreateFreeIpaRequest source = new CreateFreeIpaRequest();
    source.setEnvironmentCrn("envCrn");
    source.setName("dummyName");
    source.setVariant("AWS_NATIVE");
    source.setAuthentication(new StackAuthenticationRequest());
    source.setTelemetry(new TelemetryRequest());
    source.setInstanceGroups(List.of(new InstanceGroupRequest()));
    FreeIpaServerRequest freeIpaServerRequest = new FreeIpaServerRequest();
    freeIpaServerRequest.setDomain("dummyDomain");
    freeIpaServerRequest.setHostname("dummyHostName");
    source.setNetwork(new NetworkRequest());
    source.setFreeIpa(freeIpaServerRequest);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build());
    Future<String> owner = CompletableFuture.completedFuture("dummyUser");
    when(crnService.createCrn(ACCOUNT_ID, CrnResourceDescriptor.FREEIPA)).thenReturn("resourceCrn");
    when(stackAuthenticationConverter.convert(source.getAuthentication())).thenReturn(new StackAuthentication());
    when(instanceGroupConverter.convert(any(), any(), any(), any(), any(), any(), mapCaptorForEncryption.capture())).thenReturn(new InstanceGroup());
    when(networkConverter.convert(any(NetworkRequest.class))).thenReturn(new Network());
    when(telemetryConverter.convert(source.getTelemetry())).thenReturn(new Telemetry());
    when(backupConverter.convert(source.getTelemetry())).thenReturn(new Backup());
    when(entitlementService.internalTenant(ACCOUNT_ID)).thenReturn(Boolean.FALSE);
    when(costTagging.prepareDefaultTags(any())).thenReturn(new HashMap<>());
    Stack stack = underTest.convert(source, environmentResponse, ACCOUNT_ID, owner, "crn1", CloudPlatform.AWS.name());
    assertEquals(stack.getPlatformvariant(), "AWS_NATIVE");
    assertNull(mapCaptorForEncryption.getValue().get(GCP_KMS_ENCRYPTION_KEY));
    assertNull(mapCaptorForEncryption.getValue().get(DISK_ENCRYPTION_SET_ID));
}
Also used : StackAuthenticationRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.security.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.freeipa.entity.StackAuthentication) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) Backup(com.sequenceiq.freeipa.api.model.Backup) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Stack(com.sequenceiq.freeipa.entity.Stack) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) Network(com.sequenceiq.freeipa.entity.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FreeIpaServerRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest) Test(org.junit.jupiter.api.Test)

Example 17 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class FreeIpaTestDto method withNetwork.

private FreeIpaTestDto withNetwork(NetworkV4TestDto network) {
    NetworkV4Request request = network.getRequest();
    NetworkRequest networkRequest = new NetworkRequest();
    if (request.getAws() != null) {
        AwsNetworkParameters params = new AwsNetworkParameters();
        if (!getCloudProvider().isMultiAZ()) {
            params.setSubnetId(request.getAws().getSubnetId());
        }
        params.setVpcId(request.getAws().getVpcId());
        networkRequest.setAws(params);
    } else if (request.getMock() != null) {
        MockNetworkParameters parameters = new MockNetworkParameters();
        parameters.setSubnetId(request.getMock().getSubnetId());
        parameters.setVpcId(request.getMock().getVpcId());
        parameters.setInternetGatewayId(request.getMock().getInternetGatewayId());
        networkRequest.setMock(parameters);
    } else if (request.getGcp() != null) {
        GcpNetworkParameters gcp = new GcpNetworkParameters();
        gcp.setNetworkId(request.getGcp().getNetworkId());
        if (!getCloudProvider().isMultiAZ()) {
            gcp.setSubnetId(request.getGcp().getSubnetId());
        }
        gcp.setNoFirewallRules(request.getGcp().getNoFirewallRules());
        gcp.setNoPublicIp(request.getGcp().getNoPublicIp());
        gcp.setSharedProjectId(request.getGcp().getSharedProjectId());
        networkRequest.setGcp(gcp);
    } else if (request.getAzure() != null) {
        AzureNetworkParameters azure = new AzureNetworkParameters();
        azure.setNetworkId(request.getAzure().getNetworkId());
        azure.setNoPublicIp(request.getAzure().getNoPublicIp());
        azure.setSubnetId(request.getAzure().getSubnetId());
        azure.setResourceGroupName(request.getAzure().getResourceGroupName());
        networkRequest.setAzure(azure);
    }
    getRequest().setNetwork(networkRequest);
    return this;
}
Also used : AzureNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters) MockNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters) 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) GcpNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.GcpNetworkParameters) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) InstanceGroupNetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request)

Example 18 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class AzureCloudProvider method networkRequest.

@Override
public NetworkRequest networkRequest(FreeIpaTestDto dto) {
    NetworkRequest networkRequest = new NetworkRequest();
    AzureNetworkParameters networkParameters = new AzureNetworkParameters();
    networkParameters.setSubnetId(getSubnetId());
    networkParameters.setNetworkId(getNetworkId());
    networkParameters.setNoPublicIp(getNoPublicIp());
    networkParameters.setResourceGroupName(getResourceGroupName());
    networkRequest.setAzure(networkParameters);
    return networkRequest;
}
Also used : AzureNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.AzureNetworkParameters) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

Example 19 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class GcpCloudProvider method networkRequest.

@Override
public NetworkRequest networkRequest(FreeIpaTestDto dto) {
    NetworkRequest networkRequest = new NetworkRequest();
    GcpNetworkParameters networkParameters = new GcpNetworkParameters();
    networkParameters.setSubnetId(getSubnetId());
    networkParameters.setNetworkId(getNetworkId());
    networkParameters.setNoPublicIp(getNoPublicIp());
    networkParameters.setNoFirewallRules(getNoFirewallRules());
    networkParameters.setSharedProjectId(getSharedProjectId());
    networkRequest.setGcp(networkParameters);
    return networkRequest;
}
Also used : NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest) GcpNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.GcpNetworkParameters)

Example 20 with NetworkRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest in project cloudbreak by hortonworks.

the class MockCloudProvider method networkRequest.

@Override
public NetworkRequest networkRequest(FreeIpaTestDto dto) {
    NetworkRequest networkRequest = new NetworkRequest();
    MockNetworkParameters networkParameters = new MockNetworkParameters();
    networkParameters.setSubnetId(getSubnetId());
    networkParameters.setVpcId(getVpcId());
    networkParameters.setInternetGatewayId(getInternetGatewayId());
    networkRequest.setMock(networkParameters);
    return networkRequest;
}
Also used : MockNetworkParameters(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.MockNetworkParameters) NetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.network.NetworkRequest)

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