Search in sources :

Example 6 with DatabaseVendor

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));
    }
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 7 with DatabaseVendor

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;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) DatabaseConfig(com.sequenceiq.redbeams.domain.DatabaseConfig)

Example 8 with DatabaseVendor

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;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 9 with DatabaseVendor

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;
}
Also used : DatabaseVendor(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig)

Aggregations

DatabaseVendor (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor)8 Test (org.junit.Test)2 DatabaseV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.DatabaseV4Request)1 OracleParameters (com.sequenceiq.cloudbreak.api.endpoint.v4.database.requests.OracleParameters)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 DatabaseConfig (com.sequenceiq.redbeams.domain.DatabaseConfig)1 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)1 DatabaseServer (com.sequenceiq.redbeams.domain.stack.DatabaseServer)1 Date (java.util.Date)1 EnumMap (java.util.EnumMap)1