Search in sources :

Example 11 with RDSConfig

use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.

the class AmbariDatabaseMapperTest method testMapAmbariDatabaseDetailsJsonToRdsConfig.

@Test
public void testMapAmbariDatabaseDetailsJsonToRdsConfig() {
    RDSConfig rdsConfig = mapper.mapAmbariDatabaseDetailsJsonToRdsConfig(json, cluster, null, false);
    assertEquals(mapper.mapName(null, cluster), rdsConfig.getName());
    assertEquals(mapper.mapConnectionUrl(json), rdsConfig.getConnectionURL());
    assertEquals(ResourceStatus.USER_MANAGED, rdsConfig.getStatus());
    assertEquals(RdsType.AMBARI.name(), rdsConfig.getType());
    assertEquals("org.postgresql.Driver", rdsConfig.getConnectionDriver());
    assertNull(rdsConfig.getId());
    assertNull(rdsConfig.getClusters());
    assertNull(rdsConfig.getStackVersion());
    assertNotNull(rdsConfig.getCreationDate());
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Test(org.junit.Test)

Example 12 with RDSConfig

use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.

the class RDSConfigRequestToRDSConfigConverterTest method mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties.

@Test
public void mysqlJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnMysqlVendorProperties() {
    RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
    rdsConfigRequest.setConnectionURL("jdbc:mysql://test.eu-west-1.rds.amazonaws.com:5432/test");
    RDSConfig rdsConfig = underTest.convert(rdsConfigRequest);
    Assert.assertEquals(rdsConfigRequest.getConnectionPassword(), rdsConfig.getConnectionPassword());
    Assert.assertEquals(rdsConfigRequest.getConnectionUserName(), rdsConfig.getConnectionUserName());
    Assert.assertEquals(rdsConfigRequest.getConnectionURL(), rdsConfig.getConnectionURL());
    Assert.assertEquals(rdsConfigRequest.getType(), rdsConfig.getType());
    Assert.assertEquals(rdsConfigRequest.getName(), rdsConfig.getName());
    Assert.assertEquals(DatabaseVendor.MYSQL.connectionDriver(), rdsConfig.getConnectionDriver());
    Assert.assertEquals(DatabaseVendor.MYSQL.name(), rdsConfig.getDatabaseEngine());
    verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) APIResourceType(com.sequenceiq.cloudbreak.common.type.APIResourceType) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) Test(org.junit.Test)

Example 13 with RDSConfig

use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.

the class TestUtil method rdsConfig.

public static RDSConfig rdsConfig(RdsType rdsType) {
    RDSConfig rdsConfig = new RDSConfig();
    rdsConfig.setName(rdsType.name());
    rdsConfig.setConnectionPassword("iamsoosecure");
    rdsConfig.setConnectionUserName("heyitsme");
    rdsConfig.setConnectionURL("jdbc:postgresql://10.1.1.1:5432/" + rdsType.name().toLowerCase());
    rdsConfig.setType(rdsType.name());
    rdsConfig.setConnectionDriver("org.postgresql.Driver");
    rdsConfig.setDatabaseEngine(DatabaseVendor.POSTGRES.name());
    return rdsConfig;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig)

Example 14 with RDSConfig

use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.

the class AmbariDatabaseMapperImpl method mapAmbariDatabaseDetailsJsonToRdsConfig.

@Override
public RDSConfig mapAmbariDatabaseDetailsJsonToRdsConfig(AmbariDatabaseDetailsJson ambariDatabaseDetailsJson, Cluster cluster, Stack stack, boolean publicInAccount) {
    if (ambariDatabaseDetailsJson == null && cluster == null) {
        return null;
    }
    RDSConfig rDSConfig = new RDSConfig();
    if (ambariDatabaseDetailsJson != null) {
        rDSConfig.setConnectionUserName(ambariDatabaseDetailsJson.getUserName());
        if (ambariDatabaseDetailsJson.getVendor() != null) {
            rDSConfig.setDatabaseEngine(ambariDatabaseDetailsJson.getVendor().name());
        }
        rDSConfig.setConnectionURL(mapConnectionUrl(ambariDatabaseDetailsJson));
        rDSConfig.setConnectionPassword(ambariDatabaseDetailsJson.getPassword());
    }
    if (cluster != null) {
        rDSConfig.setName(mapName(stack, cluster));
        rDSConfig.setAccount(cluster.getAccount());
        rDSConfig.setOwner(cluster.getOwner());
    }
    rDSConfig.setPublicInAccount(publicInAccount);
    rDSConfig.setCreationDate(new java.util.Date().getTime());
    rDSConfig.setType(com.sequenceiq.cloudbreak.api.model.rds.RdsType.AMBARI.name());
    rDSConfig.setConnectionDriver("org.postgresql.Driver");
    rDSConfig.setStatus(com.sequenceiq.cloudbreak.api.model.ResourceStatus.USER_MANAGED);
    return rDSConfig;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig)

Example 15 with RDSConfig

use of com.sequenceiq.cloudbreak.domain.RDSConfig in project cloudbreak by hortonworks.

the class ClusterToClusterDetailsConverter method addDatabaseInfo.

private void addDatabaseInfo(ClusterDetails clusterDetails, Cluster source) {
    RDSConfig rdsConfig = rdsConfigService.findByClusterIdAndType(source.getOwner(), source.getAccount(), source.getId(), RdsType.AMBARI);
    if (rdsConfig == null || DatabaseVendor.EMBEDDED.name().equalsIgnoreCase(rdsConfig.getDatabaseEngine())) {
        clusterDetails.setDatabaseType(DatabaseVendor.EMBEDDED.name());
        clusterDetails.setExternalDatabase(Boolean.FALSE);
    } else {
        clusterDetails.setDatabaseType(rdsConfig.getDatabaseEngine());
        clusterDetails.setExternalDatabase(Boolean.TRUE);
    }
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig)

Aggregations

RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)47 Test (org.junit.Test)16 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)6 RDSConfigRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)5 Date (java.util.Date)5 HashSet (java.util.HashSet)5 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)4 Json (com.sequenceiq.cloudbreak.domain.json.Json)4 IOException (java.io.IOException)4 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)3 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)2 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)2 ConfigsResponse (com.sequenceiq.cloudbreak.api.model.ConfigsResponse)2 RdsView (com.sequenceiq.cloudbreak.blueprint.template.views.RdsView)2 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)2