Search in sources :

Example 21 with RDSConfig

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

the class RdsConfigService method get.

public RDSConfig get(Long id) {
    RDSConfig rdsConfig = rdsConfigRepository.findById(id);
    if (rdsConfig == null) {
        throw new NotFoundException(String.format("RDS configuration '%s' not found.", id));
    }
    authorizationService.hasReadPermission(rdsConfig);
    return rdsConfig;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 22 with RDSConfig

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

the class RdsConfigService method getByName.

public RDSConfig getByName(String name, IdentityUser user) {
    RDSConfig rdsConfig = rdsConfigRepository.findOneByName(name, user.getAccount());
    if (rdsConfig == null) {
        throw new NotFoundException(String.format("RDS configuration '%s' not found.", name));
    }
    authorizationService.hasReadPermission(rdsConfig);
    return rdsConfig;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 23 with RDSConfig

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

the class AbstractRdsConfigProvider method createServicePillarConfigMapIfNeeded.

public Map<String, Object> createServicePillarConfigMapIfNeeded(Stack stack, Cluster cluster) {
    if (isRdsConfigNeeded(cluster.getBlueprint())) {
        Set<RDSConfig> rdsConfigs = createPostgresRdsConfigIfNeeded(stack, cluster);
        RDSConfig rdsConfig = rdsConfigs.stream().filter(rdsConfig1 -> rdsConfig1.getType().equalsIgnoreCase(getRdsType().name())).findFirst().get();
        Map<String, Object> postgres = new HashMap<>();
        postgres.put("database", getDb());
        postgres.put("user", getDbUser());
        postgres.put("password", rdsConfig.getConnectionPassword());
        return Collections.singletonMap(getPillarKey(), postgres);
    }
    return Collections.emptyMap();
}
Also used : HashMap(java.util.HashMap) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig)

Example 24 with RDSConfig

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

the class RdsViewTest method testCreateRdsViewWhenRDSConfigContainsProperConnectionUrl.

@Test
public void testCreateRdsViewWhenRDSConfigContainsProperConnectionUrl() {
    String connectionUrl = "jdbc:postgresql://some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com:5432/ranger";
    RDSConfig rdsConfig = createRdsConfig(connectionUrl);
    RdsView underTest = new RdsView(rdsConfig);
    Assert.assertEquals(ASSERT_ERROR_MSG, "some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com:5432", underTest.getHostWithPort());
    Assert.assertEquals("postgresql", underTest.getSubprotocol());
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Test(org.junit.Test)

Example 25 with RDSConfig

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

the class RdsViewTest method testCreateRdsViewWhenRDSConfigContainsConnectionUrlWithoutDatabaseNameAndPortAndJDBCPrefix.

@Test
public void testCreateRdsViewWhenRDSConfigContainsConnectionUrlWithoutDatabaseNameAndPortAndJDBCPrefix() {
    String connectionUrl = "some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com";
    RDSConfig rdsConfig = createRdsConfig(connectionUrl);
    RdsView underTest = new RdsView(rdsConfig);
    Assert.assertEquals(ASSERT_ERROR_MSG, "some-rds.1d3nt1f13r.eu-west-1.rds.amazonaws.com", underTest.getHostWithPort());
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Test(org.junit.Test)

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