use of com.sequenceiq.redbeams.domain.stack.DatabaseServer 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;
}
Aggregations