Search in sources :

Example 6 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverter method convert.

public StackDatabaseServerResponse convert(DatabaseServerV4Response databaseServerV4Response) {
    StackDatabaseServerResponse stackDatabaseServerResponse = new StackDatabaseServerResponse();
    stackDatabaseServerResponse.setCrn(databaseServerV4Response.getCrn());
    stackDatabaseServerResponse.setName(databaseServerV4Response.getName());
    stackDatabaseServerResponse.setDescription(databaseServerV4Response.getDescription());
    stackDatabaseServerResponse.setEnvironmentCrn(databaseServerV4Response.getEnvironmentCrn());
    stackDatabaseServerResponse.setHost(databaseServerV4Response.getHost());
    stackDatabaseServerResponse.setPort(databaseServerV4Response.getPort());
    stackDatabaseServerResponse.setDatabaseVendor(databaseServerV4Response.getDatabaseVendor());
    stackDatabaseServerResponse.setDatabaseVendorDisplayName(databaseServerV4Response.getDatabaseVendorDisplayName());
    stackDatabaseServerResponse.setCreationDate(databaseServerV4Response.getCreationDate());
    if (databaseServerV4Response.getResourceStatus() != null) {
        stackDatabaseServerResponse.setResourceStatus(resourceStatusToDatabaseServerResourceStatus(databaseServerV4Response.getResourceStatus()));
    }
    if (databaseServerV4Response.getStatus() != null) {
        stackDatabaseServerResponse.setStatus(statusToDatabaseServerStatus(databaseServerV4Response.getStatus()));
    }
    stackDatabaseServerResponse.setStatusReason(databaseServerV4Response.getStatusReason());
    stackDatabaseServerResponse.setClusterCrn(databaseServerV4Response.getClusterCrn());
    if (databaseServerV4Response.getSslConfig() != null) {
        SslConfigV4Response sslConfig = databaseServerV4Response.getSslConfig();
        DatabaseServerSslConfig databaseServerSslConfig = new DatabaseServerSslConfig();
        databaseServerSslConfig.setSslCertificates(sslConfig.getSslCertificates());
        if (sslConfig.getSslMode() != null) {
            databaseServerSslConfig.setSslMode(sslModeToDatabaseServerSslMode(sslConfig.getSslMode()));
        }
        if (sslConfig.getSslCertificateType() != null) {
            databaseServerSslConfig.setSslCertificateType(sslCertificateTypeToDatabaseServerSslCertificateType(sslConfig.getSslCertificateType()));
        }
        stackDatabaseServerResponse.setSslConfig(databaseServerSslConfig);
    }
    return stackDatabaseServerResponse;
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)

Example 7 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverter method convert.

public StackDatabaseServerResponse convert(DatabaseServerV4Response databaseServerV4Response) {
    StackDatabaseServerResponse stackDatabaseServerResponse = new StackDatabaseServerResponse();
    stackDatabaseServerResponse.setCrn(databaseServerV4Response.getCrn());
    stackDatabaseServerResponse.setName(databaseServerV4Response.getName());
    stackDatabaseServerResponse.setDescription(databaseServerV4Response.getDescription());
    stackDatabaseServerResponse.setEnvironmentCrn(databaseServerV4Response.getEnvironmentCrn());
    stackDatabaseServerResponse.setHost(databaseServerV4Response.getHost());
    stackDatabaseServerResponse.setPort(databaseServerV4Response.getPort());
    stackDatabaseServerResponse.setDatabaseVendor(databaseServerV4Response.getDatabaseVendor());
    stackDatabaseServerResponse.setDatabaseVendorDisplayName(databaseServerV4Response.getDatabaseVendorDisplayName());
    stackDatabaseServerResponse.setCreationDate(databaseServerV4Response.getCreationDate());
    if (databaseServerV4Response.getResourceStatus() != null) {
        stackDatabaseServerResponse.setResourceStatus(resourceStatusToDatabaseServerResourceStatus(databaseServerV4Response.getResourceStatus()));
    }
    if (databaseServerV4Response.getStatus() != null) {
        stackDatabaseServerResponse.setStatus(statusToDatabaseServerStatus(databaseServerV4Response.getStatus()));
    }
    stackDatabaseServerResponse.setStatusReason(databaseServerV4Response.getStatusReason());
    stackDatabaseServerResponse.setClusterCrn(databaseServerV4Response.getClusterCrn());
    if (databaseServerV4Response.getSslConfig() != null) {
        SslConfigV4Response sslConfig = databaseServerV4Response.getSslConfig();
        DatabaseServerSslConfig databaseServerSslConfig = new DatabaseServerSslConfig();
        databaseServerSslConfig.setSslCertificates(sslConfig.getSslCertificates());
        if (sslConfig.getSslMode() != null) {
            databaseServerSslConfig.setSslMode(sslModeToDatabaseServerSslMode(sslConfig.getSslMode()));
        }
        if (sslConfig.getSslCertificateType() != null) {
            databaseServerSslConfig.setSslCertificateType(sslCertificateTypeToDatabaseServerSslCertificateType(sslConfig.getSslCertificateType()));
        }
        stackDatabaseServerResponse.setSslConfig(databaseServerSslConfig);
    }
    return stackDatabaseServerResponse;
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)

Example 8 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverterTest method testConvertResponse.

@Test
public void testConvertResponse() {
    DatabaseServerV4Response source = new DatabaseServerV4Response();
    source.setCrn("databaseCrn");
    source.setName("databaseName");
    source.setDescription("description");
    source.setEnvironmentCrn("envCrn");
    source.setHost("host");
    source.setPort(1234);
    source.setDatabaseVendor("vendor");
    source.setDatabaseVendorDisplayName("vendorName");
    source.setCreationDate(new Date().getTime());
    source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    source.setStatus(Status.AVAILABLE);
    source.setStatusReason("Everything is great");
    source.setClusterCrn("clusterCrn");
    SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
    sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
    sourceSslConfig.setSslMode(SslMode.ENABLED);
    sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    source.setSslConfig(sourceSslConfig);
    StackDatabaseServerResponse result = underTest.convert(source);
    assertEquals(source.getCrn(), result.getCrn());
    assertEquals(source.getName(), result.getName());
    assertEquals(source.getDescription(), result.getDescription());
    assertEquals(source.getEnvironmentCrn(), result.getEnvironmentCrn());
    assertEquals(source.getHost(), result.getHost());
    assertEquals(source.getPort(), result.getPort());
    assertEquals(source.getDatabaseVendor(), result.getDatabaseVendor());
    assertEquals(source.getDatabaseVendorDisplayName(), result.getDatabaseVendorDisplayName());
    assertEquals(source.getCreationDate(), result.getCreationDate());
    assertEquals(DatabaseServerResourceStatus.SERVICE_MANAGED, result.getResourceStatus());
    assertEquals(DatabaseServerStatus.AVAILABLE, result.getStatus());
    assertEquals(source.getStatusReason(), result.getStatusReason());
    assertEquals(source.getClusterCrn(), result.getClusterCrn());
    DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
    assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
    assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
    assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Date(java.util.Date) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverterTest method testConvertResponse.

@Test
public void testConvertResponse() {
    DatabaseServerV4Response source = new DatabaseServerV4Response();
    source.setCrn("databaseCrn");
    source.setName("databaseName");
    source.setDescription("description");
    source.setEnvironmentCrn("envCrn");
    source.setHost("host");
    source.setPort(1234);
    source.setDatabaseVendor("vendor");
    source.setDatabaseVendorDisplayName("vendorName");
    source.setCreationDate(new Date().getTime());
    source.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    source.setStatus(Status.AVAILABLE);
    source.setStatusReason("Everything is great");
    source.setClusterCrn("clusterCrn");
    SslConfigV4Response sourceSslConfig = new SslConfigV4Response();
    sourceSslConfig.setSslCertificates(Set.of("cert1", "cert2"));
    sourceSslConfig.setSslMode(SslMode.ENABLED);
    sourceSslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    source.setSslConfig(sourceSslConfig);
    StackDatabaseServerResponse result = underTest.convert(source);
    assertThat(result.getCrn()).isEqualTo(source.getCrn());
    assertThat(result.getName()).isEqualTo(source.getName());
    assertThat(result.getDescription()).isEqualTo(source.getDescription());
    assertThat(result.getEnvironmentCrn()).isEqualTo(source.getEnvironmentCrn());
    assertThat(result.getHost()).isEqualTo(source.getHost());
    assertThat(result.getPort()).isEqualTo(source.getPort());
    assertThat(result.getDatabaseVendor()).isEqualTo(source.getDatabaseVendor());
    assertThat(result.getDatabaseVendorDisplayName()).isEqualTo(source.getDatabaseVendorDisplayName());
    assertThat(result.getCreationDate()).isEqualTo(source.getCreationDate());
    assertThat(result.getResourceStatus()).isEqualTo(DatabaseServerResourceStatus.SERVICE_MANAGED);
    assertThat(result.getStatus()).isEqualTo(DatabaseServerStatus.AVAILABLE);
    assertThat(result.getStatusReason()).isEqualTo(source.getStatusReason());
    assertThat(result.getClusterCrn()).isEqualTo(source.getClusterCrn());
    DatabaseServerSslConfig resultSslConfig = result.getSslConfig();
    assertThat(resultSslConfig.getSslMode()).isEqualTo(DatabaseServerSslMode.ENABLED);
    assertThat(resultSslConfig.getSslCertificateType()).isEqualTo(DatabaseServerSslCertificateType.CLOUD_PROVIDER_OWNED);
    assertThat(resultSslConfig.getSslCertificates()).isEqualTo(sourceSslConfig.getSslCertificates());
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Date(java.util.Date) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class RedbeamsDbCertificateProvider method getDatabaseRootCerts.

private Set<String> getDatabaseRootCerts(Cluster cluster) {
    Set<String> result = new HashSet<>();
    if (dbServerConfigurer.isRemoteDatabaseNeeded(cluster)) {
        String stackResourceCrn = cluster.getStack().getResourceCrn();
        String clusterName = cluster.getName();
        LOGGER.info("Gathering cluster's(crn:'{}', name: '{}') remote database root certificates", stackResourceCrn, clusterName);
        String databaseServerCrn = cluster.getDatabaseServerCrn();
        DatabaseServerV4Response databaseServer = dbServerConfigurer.getDatabaseServer(databaseServerCrn);
        SslConfigV4Response sslConfig = databaseServer.getSslConfig();
        if (sslConfig != null) {
            if (SslMode.isEnabled(sslConfig.getSslMode())) {
                Set<String> sslCertificates = sslConfig.getSslCertificates();
                result.addAll(sslCertificates);
                LOGGER.info("Number of certificates found:'{}' for cluster(crn:'{}', name: '{}')", sslCertificates.size(), stackResourceCrn, clusterName);
            }
        } else {
            LOGGER.info("There no SSL config could be found for the remote database('{}').", databaseServerCrn);
        }
    }
    return result;
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) HashSet(java.util.HashSet)

Aggregations

SslConfigV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)14 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)11 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DatabaseServerSslConfig (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)4 StackDatabaseServerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse)4 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)4 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)3 Date (java.util.Date)2 HashSet (java.util.HashSet)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1