use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class TemplateHandler method accept.
@Override
public void accept(Event<GetPlatformTemplateRequest> platformTemplateRequestEvent) {
LOGGER.info("Received event: {}", platformTemplateRequestEvent);
GetPlatformTemplateRequest request = platformTemplateRequestEvent.getData();
String template = null;
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
if (connector != null) {
template = connector.resources().getStackTemplate();
}
} catch (TemplatingDoesNotSupportedException ignored) {
}
GetPlatformTemplateResult getPlatformTemplateResult = new GetPlatformTemplateResult(request, template);
request.getResult().onNext(getPlatformTemplateResult);
LOGGER.info("Get template finished.");
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class UpscaleStackHandler method accept.
@Override
public void accept(Event<UpscaleStackRequest> upscaleStackRequestEvent) {
LOGGER.info("Received event: {}", upscaleStackRequestEvent);
UpscaleStackRequest request = upscaleStackRequestEvent.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
List<CloudResourceStatus> resourceStatus = connector.resources().upscale(ac, request.getCloudStack(), request.getResourceList());
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);
}
UpscaleStackResult result = ResourcesStatePollerResults.transformToUpscaleStackResult(statePollerResult, request);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(upscaleStackRequestEvent.getHeaders(), result));
LOGGER.info("Upscale successfully finished for {}", cloudContext);
} catch (Exception e) {
UpscaleStackResult result = new UpscaleStackResult(e.getMessage(), e, request);
request.getResult().onNext(result);
eventBus.notify(CloudPlatformResult.failureSelector(UpscaleStackResult.class), new Event<>(upscaleStackRequestEvent.getHeaders(), result));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CloudPlatformConnectors method cloudPlatformConnectors.
@PostConstruct
public void cloudPlatformConnectors() {
platformToVariants = HashMultimap.create();
for (CloudConnector connector : cloudConnectors) {
map.put(new CloudPlatformVariant(connector.platform(), connector.variant()), connector);
platformToVariants.put(connector.platform(), connector.variant());
}
Map<Platform, Variant> environmentDefaults = extractEnvironmentDefaultVariants();
setupDefaultVariants(platformToVariants, environmentDefaults);
LOGGER.debug(map.toString());
LOGGER.debug(defaultVariants.toString());
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class LaunchStackHandler method accept.
@Override
public void accept(Event<LaunchStackRequest> launchStackRequestEvent) {
LOGGER.info("Received event: {}", launchStackRequestEvent);
LaunchStackRequest request = launchStackRequestEvent.getData();
CloudContext cloudContext = request.getCloudContext();
try {
CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
List<CloudResourceStatus> resourceStatus = connector.resources().launch(ac, request.getCloudStack(), persistenceNotifier, request.getAdjustmentType(), request.getThreshold());
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);
}
LaunchStackResult result = ResourcesStatePollerResults.transformToLaunchStackResult(request, statePollerResult);
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(launchStackRequestEvent.getHeaders(), result));
LOGGER.info("Launching the stack successfully finished for {}", cloudContext);
} catch (Exception e) {
LaunchStackResult failure = new LaunchStackResult(e, request);
LOGGER.error("Error during launching the stack:", e);
request.getResult().onNext(failure);
eventBus.notify(failure.selector(), new Event<>(launchStackRequestEvent.getHeaders(), failure));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class PlatformParameterHandler method accept.
@Override
public void accept(Event<PlatformParameterRequest> platformParameterRequestEvent) {
LOGGER.info("Received event: {}", platformParameterRequestEvent);
PlatformParameterRequest request = platformParameterRequestEvent.getData();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
PlatformParameters platformParameters = connector.parameters();
PlatformParameterResult platformParameterResult = new PlatformParameterResult(request, platformParameters);
request.getResult().onNext(platformParameterResult);
LOGGER.info("Query platform parameters finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new PlatformParameterResult(e.getMessage(), e, request));
}
}
Aggregations