use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.
the class StreamingAppRdsRoleConfigProviderUtilTest method testDataBaseTypeForCM.
@Test
public void testDataBaseTypeForCM() {
EnumMap<DatabaseVendor, String> expected = new EnumMap<>(DatabaseVendor.class);
for (DatabaseVendor vendor : DatabaseVendor.values()) {
expected.put(vendor, vendor.databaseType());
}
expected.put(DatabaseVendor.POSTGRES, "postgresql");
for (DatabaseVendor vendor : DatabaseVendor.values()) {
assertThat(dataBaseTypeForCM(vendor)).isEqualTo(expected.get(vendor));
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.
the class DatabaseV4RequestToDatabaseConfigConverter method convert.
public DatabaseConfig convert(DatabaseV4Request source) {
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setName(source.getName());
databaseConfig.setDescription(source.getDescription());
databaseConfig.setConnectionURL(source.getConnectionURL());
DatabaseVendor databaseVendor = databaseVendorUtil.getVendorByJdbcUrl(source.getConnectionURL()).get();
databaseConfig.setDatabaseVendor(databaseVendor);
databaseConfig.setConnectionDriver(source.getConnectionDriver());
databaseConfig.setConnectionUserName(source.getConnectionUserName());
databaseConfig.setConnectionPassword(source.getConnectionPassword());
databaseConfig.setCreationDate(clock.getCurrentTimeMillis());
databaseConfig.setStatus(ResourceStatus.USER_MANAGED);
databaseConfig.setType(source.getType());
databaseConfig.setEnvironmentId(source.getEnvironmentCrn());
return databaseConfig;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverter method buildDatabaseServer.
private DatabaseServer buildDatabaseServer(DatabaseServerV4StackRequest source, CloudPlatform cloudPlatform, Crn ownerCrn, SecurityAccessResponse securityAccessResponse) {
DatabaseServer server = new DatabaseServer();
server.setAccountId(ownerCrn.getAccountId());
server.setName(generateDatabaseServerName());
server.setInstanceType(source.getInstanceType());
DatabaseVendor databaseVendor = DatabaseVendor.fromValue(source.getDatabaseVendor());
server.setDatabaseVendor(databaseVendor);
server.setConnectionDriver(source.getConnectionDriver());
server.setStorageSize(source.getStorageSize());
server.setRootUserName(source.getRootUserName() != null ? source.getRootUserName() : userGeneratorService.generateUserName());
server.setRootPassword(source.getRootUserPassword() != null ? source.getRootUserPassword() : passwordGeneratorService.generatePassword(Optional.of(cloudPlatform)));
server.setPort(source.getPort());
server.setSecurityGroup(buildExistingSecurityGroup(source.getSecurityGroup(), securityAccessResponse));
Map<String, Object> parameters = providerParameterCalculator.get(source).asMap();
if (parameters != null) {
try {
setDbVersion(parameters, cloudPlatform);
server.setAttributes(new Json(parameters));
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid database server parameters", e);
}
}
return server;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor in project cloudbreak by hortonworks.
the class DatabaseServerV4RequestToDatabaseServerConfigConverter method convert.
public DatabaseServerConfig convert(DatabaseServerV4Request source) {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setName(source.getName());
server.setDescription(source.getDescription());
server.setHost(source.getHost());
server.setPort(source.getPort());
DatabaseVendor databaseVendor = DatabaseVendor.fromValue(source.getDatabaseVendor());
server.setDatabaseVendor(databaseVendor);
server.setConnectionDriver(source.getConnectionDriver());
server.setConnectionUserName(source.getConnectionUserName());
server.setConnectionPassword(source.getConnectionPassword());
server.setResourceStatus(ResourceStatus.USER_MANAGED);
server.setArchived(false);
server.setDeletionTimestamp(null);
server.setEnvironmentId(source.getEnvironmentCrn());
return server;
}
Aggregations