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;
}
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;
}
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());
}
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());
}
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;
}
Aggregations