use of com.sequenceiq.cloudbreak.cloud.context.CloudContext 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.context.CloudContext in project cloudbreak by hortonworks.
the class SshUserHandler method accept.
@Override
public void accept(Event<SshUserRequest> event) {
LOGGER.info("Received event: {}", event);
SshUserRequest request = event.getData();
CloudContext cloudContext = request.getCloudContext();
request.getResult().onNext(new SshUserResponse(cloudContext, request.getLoginUserName()));
}
use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.
the class FileSystemValidator method validateFileSystem.
public void validateFileSystem(String platform, CloudCredential cloudCredential, FileSystemRequest fileSystemRequest) {
if (fileSystemRequest == null) {
return;
}
validateFilesystemRequest(fileSystemRequest);
LOGGER.debug("Sending fileSystemRequest to {} to validate the file system", platform);
CloudContext cloudContext = new CloudContext(null, null, platform, null, null, null);
FileSystem fileSystem = converter.convert(fileSystemRequest);
FileSystemValidationRequest request = new FileSystemValidationRequest(fileSystem, cloudCredential, cloudContext);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
FileSystemValidationResult result = request.await();
LOGGER.info("File system validation result: {}", result);
Exception exception = result.getErrorDetails();
if (exception != null) {
throw new BadRequestException(result.getStatusReason(), exception);
}
} catch (InterruptedException e) {
LOGGER.error("Error while sending the file system validation request", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.
the class AbstractInstanceConnector method start.
@Override
public List<CloudVmInstanceStatus> start(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) {
CloudContext cloudContext = ac.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, ac, null, resources, true);
// compute
return computeResourceService.startInstances(context, ac, resources, vms);
}
use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.
the class AbstractResourceConnector method update.
@Override
public List<CloudResourceStatus> update(AuthenticatedContext auth, CloudStack stack, List<CloudResource> resources) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), resources, true);
// group
List<CloudResource> groupResources = groupResourceService.getGroupResources(platform, resources);
List<CloudResourceStatus> groupStatuses = groupResourceService.update(context, auth, stack.getNetwork(), stack.getCloudSecurity(), groupResources);
// network
List<CloudResource> networkResources = networkResourceService.getNetworkResources(platform, resources);
List<CloudResourceStatus> networkStatuses = networkResourceService.update(context, auth, stack.getNetwork(), stack.getCloudSecurity(), networkResources);
groupStatuses.addAll(networkStatuses);
return groupStatuses;
}
Aggregations