Search in sources :

Example 1 with SetupRequest

use of com.sequenceiq.cloudbreak.cloud.event.setup.SetupRequest in project cloudbreak by hortonworks.

the class ProvisionSetupHandler method accept.

@Override
public void accept(Event<SetupRequest> event) {
    LOGGER.info("Received event: {}", event);
    SetupRequest request = event.getData();
    CloudContext cloudContext = request.getCloudContext();
    SetupResult result;
    try {
        CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
        AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
        CloudStack cloudStack = request.getCloudStack();
        connector.setup().prerequisites(auth, cloudStack, resourceNotifier);
        result = new SetupResult(request);
        LOGGER.info("Provision setup finished for {}", cloudContext);
    } catch (RuntimeException e) {
        result = new SetupResult(e, request);
    }
    request.getResult().onNext(result);
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : SetupResult(com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) SetupRequest(com.sequenceiq.cloudbreak.cloud.event.setup.SetupRequest)

Aggregations

CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 SetupRequest (com.sequenceiq.cloudbreak.cloud.event.setup.SetupRequest)1 SetupResult (com.sequenceiq.cloudbreak.cloud.event.setup.SetupResult)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1