Search in sources :

Example 1 with TemplatingNotSupportedException

use of com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException in project cloudbreak by hortonworks.

the class RedbeamsCreationService method saveDbStack.

private DBStack saveDbStack(DBStack dbStack) {
    // possible future change is to use a flow here (GetPlatformTemplateRequest, modified for database server)
    // for now, just get it synchronously / within this thread, it ought to be quick
    CloudPlatformVariant platformVariant = new CloudPlatformVariant(dbStack.getCloudPlatform(), dbStack.getPlatformVariant());
    try {
        CloudConnector<Object> connector = cloudPlatformConnectors.get(platformVariant);
        if (connector == null) {
            throw new RedbeamsException("Failed to find cloud connector for platform variant " + platformVariant);
        }
        String template = connector.resources().getDBStackTemplate();
        if (template == null) {
            throw new RedbeamsException("No database stack template is available for platform variant " + platformVariant);
        }
        dbStack.setTemplate(template);
    } catch (TemplatingNotSupportedException e) {
        throw new RedbeamsException("Failed to retrieve database stack template for cloud platform", e);
    }
    DatabaseServer databaseServer = dbStack.getDatabaseServer();
    if (databaseServer.getConnectionDriver() == null) {
        String connectionDriver = databaseServer.getDatabaseVendor().connectionDriver();
        databaseServer.setConnectionDriver(connectionDriver);
        LOGGER.info("Database server allocation request lacked a connection driver; defaulting to {}", connectionDriver);
    }
    return dbStackService.save(dbStack);
}
Also used : CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) TemplatingNotSupportedException(com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException) RedbeamsException(com.sequenceiq.redbeams.exception.RedbeamsException)

Example 2 with TemplatingNotSupportedException

use of com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException in project cloudbreak by hortonworks.

the class TemplateHandler method accept.

@Override
public void accept(Event<GetPlatformTemplateRequest> platformTemplateRequestEvent) {
    LOGGER.debug("Received event: {}", platformTemplateRequestEvent);
    GetPlatformTemplateRequest request = platformTemplateRequestEvent.getData();
    String template = null;
    try {
        CloudConnector<Object> connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
        if (connector != null) {
            template = connector.resources().getStackTemplate();
        }
    } catch (TemplatingNotSupportedException ignored) {
    }
    GetPlatformTemplateResult getPlatformTemplateResult = new GetPlatformTemplateResult(request.getResourceId(), template);
    request.getResult().onNext(getPlatformTemplateResult);
    LOGGER.debug("Get template finished.");
}
Also used : GetPlatformTemplateResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult) TemplatingNotSupportedException(com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException) GetPlatformTemplateRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest)

Aggregations

TemplatingNotSupportedException (com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException)2 GetPlatformTemplateRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest)1 GetPlatformTemplateResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateResult)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 DatabaseServer (com.sequenceiq.redbeams.domain.stack.DatabaseServer)1 RedbeamsException (com.sequenceiq.redbeams.exception.RedbeamsException)1