use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class PrepareImageHandler method accept.
@Override
public void accept(Event<PrepareImageRequest> event) {
LOGGER.info("Received event: {}", event);
PrepareImageRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Image image = request.getImage();
CloudStack stack = request.getStack();
connector.setup().prepareImage(auth, stack, image);
PrepareImageResult result = new PrepareImageResult(request);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
LOGGER.info("Prepare image finished for {}", cloudContext);
} catch (RuntimeException e) {
PrepareImageResult failure = new PrepareImageResult(e, request);
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(event.getHeaders(), failure));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class ProvisionValidationHandler method accept.
@Override
public void accept(Event<ValidationRequest> event) {
LOGGER.info("Received event: {}", event);
ValidationRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
ValidationResult result;
try {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(request.getCloudContext(), request.getCloudCredential());
CloudStack cloudStack = request.getCloudStack();
for (Validator v : connector.validators()) {
v.validate(ac, cloudStack);
}
result = new ValidationResult(request);
} catch (RuntimeException e) {
result = new ValidationResult(e, request);
}
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class DownscaleStackHandler method accept.
@Override
public void accept(Event<DownscaleStackRequest> downscaleStackRequestEvent) {
LOGGER.info("Received event: {}", downscaleStackRequestEvent);
DownscaleStackRequest request = downscaleStackRequestEvent.getData();
DownscaleStackResult result;
try {
CloudContext cloudContext = request.getCloudContext();
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
List<CloudResourceStatus> resourceStatus = connector.resources().downscale(ac, request.getCloudStack(), request.getCloudResources(), request.getInstances(), request.getResourcesToScale());
List<CloudResource> resources = ResourceLists.transform(resourceStatus);
PollTask<ResourcesStatePollerResult> task = statusCheckFactory.newPollResourcesStateTask(ac, resources, true);
ResourcesStatePollerResult statePollerResult = ResourcesStatePollerResults.build(cloudContext, resourceStatus);
if (!task.completed(statePollerResult)) {
statePollerResult = syncPollingScheduler.schedule(task);
}
LOGGER.info("Downscale successfully finished for {}", cloudContext);
result = new DownscaleStackResult(request, ResourceLists.transform(statePollerResult.getResults()));
} catch (Exception e) {
LOGGER.error("Failed to handle DownscaleStackRequest.", e);
result = new DownscaleStackResult(e.getMessage(), e, request);
}
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(downscaleStackRequestEvent.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CheckImageHandler method accept.
@Override
public void accept(Event<CheckImageRequest> event) {
LOGGER.info("Received event: {}", event);
CheckImageRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
AuthenticatedContext auth = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
Image image = request.getImage();
CloudStack stack = request.getStack();
ImageStatusResult progress = connector.setup().checkImageStatus(auth, stack, image);
CheckImageResult imageResult = new CheckImageResult(request, progress.getImageStatus(), progress.getStatusProgressValue());
request.getResult().onNext(imageResult);
LOGGER.info("Provision setup finished for {}", cloudContext);
} catch (RuntimeException e) {
CheckImageResult failure = new CheckImageResult(e, request, ImageStatus.CREATE_FAILED);
request.getResult().onNext(failure);
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CheckPlatformVariantHandler method accept.
@Override
public void accept(Event<CheckPlatformVariantRequest> defaultPlatformVariantRequestEvent) {
LOGGER.info("Received event: {}", defaultPlatformVariantRequestEvent);
CheckPlatformVariantRequest request = defaultPlatformVariantRequestEvent.getData();
try {
CloudConnector cc = cloudPlatformConnectors.get(request.getCloudContext().getPlatform(), request.getCloudContext().getVariant());
Variant defaultVariant = cc.variant();
CheckPlatformVariantResult platformParameterResult = new CheckPlatformVariantResult(request, defaultVariant);
request.getResult().onNext(platformParameterResult);
LOGGER.info("Query platform variant finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new CheckPlatformVariantResult(e.getMessage(), e, request));
}
}
Aggregations