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