use of com.sequenceiq.cloudbreak.cloud.CloudConnector 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));
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class RemoveInstanceHandler method accept.
@Override
public void accept(Event<RemoveInstanceRequest> removeInstanceRequestEvent) {
RemoveInstanceRequest request = removeInstanceRequestEvent.getData();
RemoveInstanceResult 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(), Collections.emptyMap());
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("Instance remove successfully finished for {}", cloudContext);
result = new RemoveInstanceResult(new DownscaleStackResult(request, ResourceLists.transform(statePollerResult.getResults())), request);
} catch (Exception e) {
LOGGER.error("Failed to handle RemoveInstanceRequest.", e);
result = new RemoveInstanceResult(e.getMessage(), e, request);
}
eventBus.notify(result.selector(), new Event<>(removeInstanceRequestEvent.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class ResourceDefinitionHandler method accept.
@Override
public void accept(Event<ResourceDefinitionRequest> getRegionsRequestEvent) {
LOGGER.info("Received event: {}", getRegionsRequestEvent);
ResourceDefinitionRequest request = getRegionsRequestEvent.getData();
try {
CloudConnector connector = cloudPlatformConnectors.get(request.getPlatform());
String resource = request.getResource();
String definition = connector.parameters().resourceDefinition(request.getResource());
if (definition == null) {
Exception exception = new Exception("Failed to find resource definition for " + resource);
request.getResult().onNext(new ResourceDefinitionResult(exception.getMessage(), exception, request));
} else {
request.getResult().onNext(new ResourceDefinitionResult(request, definition));
}
} catch (RuntimeException e) {
request.getResult().onNext(new ResourceDefinitionResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CloudPlatformConnectorsTest method getDefaultForGcp.
@Test
public void getDefaultForGcp() {
CloudConnector conn = c.getDefault(platform("SINGLE"));
assertEquals("SINGLE", conn.variant().value());
}
use of com.sequenceiq.cloudbreak.cloud.CloudConnector in project cloudbreak by hortonworks.
the class CloudPlatformConnectorsTest method getWithEmptyVariant.
@Test
public void getWithEmptyVariant() {
CloudConnector conn = c.get(platform("MULTIWITHDEFAULT"), variant(""));
// should fall back to default
assertEquals("ONE", conn.variant().value());
}
Aggregations