Search in sources :

Example 51 with S3CloudStorageV1Parameters

use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.

the class FreeIpaConfigServiceTest method testCreateFreeIpaConfigs.

@Test
void testCreateFreeIpaConfigs() {
    String backupLocation = "s3://mybucket/test";
    Backup backup = new Backup();
    backup.setStorageLocation(backupLocation);
    backup.setS3(new S3CloudStorageV1Parameters());
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain(DOMAIN);
    freeIpa.setAdminPassword(PASSWORD);
    Stack stack = new Stack();
    stack.setCloudPlatform(CloudPlatform.AWS.name());
    stack.setBackup(backup);
    stack.setEnvironmentCrn("envcrn");
    Network network = new Network();
    network.setNetworkCidrs(List.of(CIDR));
    stack.setNetwork(network);
    when(freeIpaService.findByStack(any())).thenReturn(freeIpa);
    when(freeIpaClientFactory.getAdminUser()).thenReturn(ADMIN);
    when(networkService.getFilteredSubnetWithCidr(any())).thenReturn(subnetWithCidr);
    when(reverseDnsZoneCalculator.reverseDnsZoneForCidrs(any())).thenReturn(REVERSE_ZONE);
    when(environment.getProperty("freeipa.platform.dnssec.validation.AWS", "true")).thenReturn("true");
    GatewayConfig gatewayConfig = mock(GatewayConfig.class);
    when(gatewayConfig.getHostname()).thenReturn(HOSTNAME);
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    when(proxyConfigDtoService.getByEnvironmentCrn(anyString())).thenReturn(Optional.empty());
    Node node = new Node(PRIVATE_IP, null, null, null, HOSTNAME, DOMAIN, (String) null);
    Map<String, String> expectedHost = Map.of("ip", PRIVATE_IP, "fqdn", HOSTNAME);
    Set<Object> expectedHosts = ImmutableSet.of(expectedHost);
    FreeIpaConfigView freeIpaConfigView = underTest.createFreeIpaConfigs(stack, ImmutableSet.of(node));
    assertEquals(DOMAIN.toUpperCase(), freeIpaConfigView.getRealm());
    assertEquals(DOMAIN, freeIpaConfigView.getDomain());
    assertEquals(PASSWORD, freeIpaConfigView.getPassword());
    assertEquals(REVERSE_ZONE, freeIpaConfigView.getReverseZones());
    assertEquals(ADMIN, freeIpaConfigView.getAdminUser());
    assertEquals(HOSTNAME, freeIpaConfigView.getFreeipaToReplicate());
    assertEquals(backupLocation, freeIpaConfigView.getBackup().getLocation());
    assertEquals(CloudPlatform.AWS.name(), freeIpaConfigView.getBackup().getPlatform());
    assertEquals(expectedHosts, freeIpaConfigView.getHosts());
    assertEquals(List.of(CIDR), freeIpaConfigView.getCidrBlocks());
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Backup(com.sequenceiq.freeipa.api.model.Backup) Network(com.sequenceiq.freeipa.entity.Network) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 52 with S3CloudStorageV1Parameters

use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.

the class BackupConverterTest method testConvertFromWhenfreeIpaBackupDisabled.

@Test
public void testConvertFromWhenfreeIpaBackupDisabled() {
    // GIVEN
    BackupRequest backupRequest = new BackupRequest();
    backupRequest.setS3(new S3CloudStorageV1Parameters());
    backupRequest.setStorageLocation("s3://mybucket");
    // WHEN
    Backup result = underTestBackupDisabled.convert(backupRequest);
    // THEN
    assertThat(result, is(IsNull.nullValue()));
}
Also used : BackupRequest(com.sequenceiq.common.api.backup.request.BackupRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) Test(org.junit.jupiter.api.Test)

Example 53 with S3CloudStorageV1Parameters

use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.

the class TelemetryConverter method createLoggingFromRequest.

private Logging createLoggingFromRequest(LoggingRequest loggingRequest) {
    Logging logging = null;
    if (loggingRequest != null) {
        logging = new Logging();
        logging.setStorageLocation(loggingRequest.getStorageLocation());
        if (loggingRequest.getS3() != null) {
            S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
            s3Params.setInstanceProfile(loggingRequest.getS3().getInstanceProfile());
            logging.setS3(s3Params);
        } else if (loggingRequest.getAdlsGen2() != null) {
            AdlsGen2CloudStorageV1Parameters adlsGen2Params = new AdlsGen2CloudStorageV1Parameters();
            AdlsGen2CloudStorageV1Parameters adlsGen2FromRequest = loggingRequest.getAdlsGen2();
            adlsGen2Params.setAccountKey(adlsGen2FromRequest.getAccountKey());
            adlsGen2Params.setAccountName(adlsGen2FromRequest.getAccountName());
            adlsGen2Params.setSecure(adlsGen2FromRequest.isSecure());
            adlsGen2Params.setManagedIdentity(adlsGen2FromRequest.getManagedIdentity());
            logging.setAdlsGen2(adlsGen2Params);
        } else if (loggingRequest.getGcs() != null) {
            GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
            gcsCloudStorageV1Parameters.setServiceAccountEmail(loggingRequest.getGcs().getServiceAccountEmail());
            logging.setGcs(gcsCloudStorageV1Parameters);
        } else if (loggingRequest.getCloudwatch() != null) {
            logging.setCloudwatch(CloudwatchParams.copy(loggingRequest.getCloudwatch()));
        }
    }
    return logging;
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)

Example 54 with S3CloudStorageV1Parameters

use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.

the class TelemetryConverter method createLoggingResponseFromSource.

private LoggingResponse createLoggingResponseFromSource(Logging logging) {
    LoggingResponse loggingResponse = null;
    if (logging != null) {
        loggingResponse = new LoggingResponse();
        loggingResponse.setStorageLocation(logging.getStorageLocation());
        if (logging.getS3() != null) {
            S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
            s3Params.setInstanceProfile(logging.getS3().getInstanceProfile());
            loggingResponse.setS3(s3Params);
        } else if (logging.getAdlsGen2() != null) {
            AdlsGen2CloudStorageV1Parameters adlsGen2Params = new AdlsGen2CloudStorageV1Parameters();
            adlsGen2Params.setAccountKey(logging.getAdlsGen2().getAccountKey());
            adlsGen2Params.setAccountName(logging.getAdlsGen2().getAccountName());
            adlsGen2Params.setSecure(logging.getAdlsGen2().isSecure());
            adlsGen2Params.setManagedIdentity(logging.getAdlsGen2().getManagedIdentity());
            loggingResponse.setAdlsGen2(adlsGen2Params);
        } else if (logging.getGcs() != null) {
            GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
            gcsCloudStorageV1Parameters.setServiceAccountEmail(logging.getGcs().getServiceAccountEmail());
            loggingResponse.setGcs(gcsCloudStorageV1Parameters);
        } else if (logging.getCloudwatch() != null) {
            loggingResponse.setCloudwatch(CloudwatchParams.copy(logging.getCloudwatch()));
        }
    }
    return loggingResponse;
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) GcsCloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)

Example 55 with S3CloudStorageV1Parameters

use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.

the class AwsCloudProvider method loggingRequest.

@Override
public LoggingRequest loggingRequest(TelemetryTestDto dto) {
    LoggingRequest loggingRequest = new LoggingRequest();
    S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
    s3CloudStorageV1Parameters.setInstanceProfile(getInstanceProfile());
    loggingRequest.setS3(s3CloudStorageV1Parameters);
    loggingRequest.setStorageLocation(getBaseLocation());
    return loggingRequest;
}
Also used : S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) LoggingRequest(com.sequenceiq.common.api.telemetry.request.LoggingRequest)

Aggregations

S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)59 Test (org.junit.jupiter.api.Test)27 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)16 Logging (com.sequenceiq.common.api.telemetry.model.Logging)15 LoggingRequest (com.sequenceiq.common.api.telemetry.request.LoggingRequest)12 Test (org.junit.Test)12 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)10 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)10 StorageIdentityBase (com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)7 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)7 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)7 Backup (com.sequenceiq.freeipa.api.model.Backup)7 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)5 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)4 Features (com.sequenceiq.common.api.telemetry.model.Features)4 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)4