Search in sources :

Example 36 with RDSConfig

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

the class AmbariDatabaseToRdsConfigMigrationService method migrateClusterComponent.

private void migrateClusterComponent(ClusterComponent component) {
    Cluster cluster = component.getCluster();
    LOGGER.debug("Mapping component with id: {} from cluster name: [{}] id: [{}]", component.getId(), cluster.getName(), cluster.getId());
    try {
        if (cluster.getStatus() != Status.DELETE_COMPLETED) {
            RDSConfig rdsConfig = createRdsConfig(component, cluster);
            addRdsConfigToCluster(cluster, rdsConfig);
        }
        markClusterComponentAsMigrated(component);
    } catch (IOException e) {
        LOGGER.error("Could not read component with id [{}]", component.getId(), e);
    }
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) IOException(java.io.IOException)

Example 37 with RDSConfig

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

the class AmbariDatabaseToRdsConfigMigrationService method createRdsConfig.

private RDSConfig createRdsConfig(ClusterComponent component, Cluster cluster) throws IOException {
    LOGGER.debug("Creating RdsConfig for component id: [{}]", component.getId());
    AmbariDatabaseDetailsJson ambariDatabaseDetailsJson = ambariDatabaseMapper.mapAmbariDatabaseToAmbariDatabaseDetailJson(component.getAttributes().get(AmbariDatabase.class));
    RDSConfig rdsConfig = ambariDatabaseMapper.mapAmbariDatabaseDetailsJsonToRdsConfig(ambariDatabaseDetailsJson, cluster, null, false);
    if (DatabaseVendor.EMBEDDED.name().equalsIgnoreCase(rdsConfig.getDatabaseEngine())) {
        rdsConfig.setStatus(ResourceStatus.DEFAULT);
    }
    return rdsConfigService.create(rdsConfig);
}
Also used : AmbariDatabase(com.sequenceiq.cloudbreak.cloud.model.AmbariDatabase) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) AmbariDatabaseDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariDatabaseDetailsJson)

Example 38 with RDSConfig

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

the class RdsConfigService method delete.

public void delete(Long id, IdentityUser user) {
    RDSConfig rdsConfig = rdsConfigRepository.findByIdInAccount(id, user.getAccount());
    if (rdsConfig == null) {
        throw new NotFoundException(String.format("RDS configuration '%s' not found.", id));
    }
    delete(rdsConfig);
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException)

Example 39 with RDSConfig

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

the class RdsConfigService method delete.

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

Example 40 with RDSConfig

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

the class AbstractRdsConfigProvider method createPostgresRdsConf.

private Set<RDSConfig> createPostgresRdsConf(Stack stack, Cluster cluster, Set<RDSConfig> rdsConfigs, String dbUserName, String dbPort, String dbName) {
    RDSConfig rdsConfig = new RDSConfig();
    rdsConfig.setName(getRdsType().name() + '_' + stack.getName() + stack.getId());
    rdsConfig.setConnectionUserName(dbUserName);
    rdsConfig.setConnectionPassword(PasswordUtil.generatePassword());
    String primaryGatewayIp = stack.getPrimaryGatewayInstance().getPrivateIp();
    rdsConfig.setConnectionURL("jdbc:postgresql://" + primaryGatewayIp + ":" + dbPort + "/" + dbName);
    rdsConfig.setDatabaseEngine(RDSDatabase.POSTGRES.name());
    rdsConfig.setType(getRdsType().name());
    rdsConfig.setConnectionDriver(RDSDatabase.POSTGRES.getDbDriver());
    rdsConfig.setStatus(ResourceStatus.DEFAULT);
    rdsConfig.setCreationDate(new Date().getTime());
    rdsConfig.setOwner(stack.getOwner());
    rdsConfig.setAccount(stack.getAccount());
    rdsConfig.setClusters(Collections.singleton(cluster));
    rdsConfig = rdsConfigService.create(rdsConfig);
    if (rdsConfigs == null) {
        rdsConfigs = new HashSet<>();
    }
    rdsConfigs.add(rdsConfig);
    cluster.setRdsConfigs(rdsConfigs);
    clusterRepository.save(cluster);
    return rdsConfigs;
}
Also used : RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Date(java.util.Date)

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