Search in sources :

Example 6 with RDSConfigRequest

use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.

the class ClusterDecorator method prepareRds.

private void prepareRds(Cluster subject, IdentityUser user, ClusterRequest request, Stack stack) {
    subject.setRdsConfigs(new HashSet<>());
    if (request.getRdsConfigIds() != null) {
        for (Long rdsConfigId : request.getRdsConfigIds()) {
            RDSConfig rdsConfig = rdsConfigService.get(rdsConfigId);
            subject.getRdsConfigs().add(rdsConfig);
        }
    }
    if (request.getRdsConfigJsons() != null) {
        for (RDSConfigRequest requestRdsConfig : request.getRdsConfigJsons()) {
            RDSConfig rdsConfig = conversionService.convert(requestRdsConfig, RDSConfig.class);
            rdsConfig.setPublicInAccount(stack.isPublicInAccount());
            rdsConfig = rdsConfigService.createIfNotExists(user, rdsConfig);
            subject.getRdsConfigs().add(rdsConfig);
        }
    }
    Optional.of(request.getRdsConfigNames()).ifPresent(confs -> confs.forEach(confName -> subject.getRdsConfigs().add(rdsConfigService.getPublicRdsConfig(confName, user))));
    if (request.getAmbariDatabaseDetails() != null) {
        RDSConfig rdsConfig = ambariDatabaseMapper.mapAmbariDatabaseDetailsJsonToRdsConfig(request.getAmbariDatabaseDetails(), subject, stack, stack.isPublicInAccount());
        subject.getRdsConfigs().add(rdsConfigService.createIfNotExists(user, rdsConfig));
    }
    ambariConfigurationService.createDefaultRdsConfigIfNeeded(stack, subject).ifPresent(rdsConfig -> subject.getRdsConfigs().add(rdsConfig));
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) RdsType(com.sequenceiq.cloudbreak.api.model.rds.RdsType) LoggerFactory(org.slf4j.LoggerFactory) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) StringUtils(org.apache.commons.lang3.StringUtils) AmbariConfigurationService(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariConfigurationService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Map(java.util.Map) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Json(com.sequenceiq.cloudbreak.domain.json.Json) Stack(com.sequenceiq.cloudbreak.domain.Stack) ConversionService(org.springframework.core.convert.ConversionService) BlueprintParameter(com.sequenceiq.cloudbreak.domain.BlueprintParameter) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) RdsConnectionValidator(com.sequenceiq.cloudbreak.controller.validation.rds.RdsConnectionValidator) Logger(org.slf4j.Logger) LdapConfigValidator(com.sequenceiq.cloudbreak.controller.validation.ldapconfig.LdapConfigValidator) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) BlueprintParameterJson(com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson) LdapConfigRequest(com.sequenceiq.cloudbreak.api.model.ldap.LdapConfigRequest) Set(java.util.Set) BlueprintValidator(com.sequenceiq.cloudbreak.blueprint.validation.BlueprintValidator) IOException(java.io.IOException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BlueprintInputJson(com.sequenceiq.cloudbreak.api.model.BlueprintInputJson) ConnectedClusterRequest(com.sequenceiq.cloudbreak.api.model.ConnectedClusterRequest) BlueprintInputParameters(com.sequenceiq.cloudbreak.domain.BlueprintInputParameters) Component(org.springframework.stereotype.Component) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) AmbariDatabaseMapper(com.sequenceiq.cloudbreak.converter.mapper.AmbariDatabaseMapper) Optional(java.util.Optional) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) LdapConfigService(com.sequenceiq.cloudbreak.service.ldapconfig.LdapConfigService) ConfigsResponse(com.sequenceiq.cloudbreak.api.model.ConfigsResponse) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)

Example 7 with RDSConfigRequest

use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.

the class RDSConfigRequestToRDSConfigConverterTest method testConverterWhenNameIsNullThenShouldReturnGeneratedName.

@Test
public void testConverterWhenNameIsNullThenShouldReturnGeneratedName() {
    RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
    rdsConfigRequest.setName(null);
    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(NAME, rdsConfig.getName());
    Assert.assertEquals(DatabaseVendor.POSTGRES.connectionDriver(), rdsConfig.getConnectionDriver());
    Assert.assertEquals(DatabaseVendor.POSTGRES.name(), rdsConfig.getDatabaseEngine());
    verify(missingResourceNameGenerator, times(1)).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 8 with RDSConfigRequest

use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.

the class RDSConfigRequestToRDSConfigConverterTest method postgresJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnPostgresVendorProperties.

@Test
public void postgresJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnPostgresVendorProperties() {
    RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
    rdsConfigRequest.setConnectionURL("jdbc:postgresql://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.POSTGRES.connectionDriver(), rdsConfig.getConnectionDriver());
    Assert.assertEquals(DatabaseVendor.POSTGRES.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 9 with RDSConfigRequest

use of com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest in project cloudbreak by hortonworks.

the class RDSConfigRequestToRDSConfigConverterTest method unsupportedJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnBadRequestException.

@Test
public void unsupportedJdbcConverterTestWhenDatabaseCanBeDetectedThenShouldReturnBadRequestException() {
    RDSConfigRequest rdsConfigRequest = rdsConfigRequest();
    rdsConfigRequest.setConnectionURL("jdbc:smalldog://test.eu-west-1.rds.amazonaws.com:5432/test");
    thrown.expect(BadRequestException.class);
    underTest.convert(rdsConfigRequest);
    verify(missingResourceNameGenerator, times(0)).generateName(any(APIResourceType.class));
}
Also used : APIResourceType(com.sequenceiq.cloudbreak.common.type.APIResourceType) RDSConfigRequest(com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest) Test(org.junit.Test)

Aggregations

RDSConfigRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigRequest)9 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)6 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)4 Test (org.junit.Test)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Strings (com.google.common.base.Strings)1 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)1 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)1 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)1 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 ConfigsResponse (com.sequenceiq.cloudbreak.api.model.ConfigsResponse)1 ConnectedClusterRequest (com.sequenceiq.cloudbreak.api.model.ConnectedClusterRequest)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 LdapConfigRequest (com.sequenceiq.cloudbreak.api.model.ldap.LdapConfigRequest)1 ProxyConfigResponse (com.sequenceiq.cloudbreak.api.model.proxy.ProxyConfigResponse)1 RDSConfigJson (com.sequenceiq.cloudbreak.api.model.rds.RDSConfigJson)1 RDSTestRequest (com.sequenceiq.cloudbreak.api.model.rds.RDSTestRequest)1