use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult in project cloudbreak by hortonworks.
the class GetPlatformVmTypesHandler method accept.
@Override
public void accept(Event<GetPlatformVmTypesRequest> getPlatformVmTypesRequest) {
LOGGER.info("Received event: {}", getPlatformVmTypesRequest);
GetPlatformVmTypesRequest request = getPlatformVmTypesRequest.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudVmTypes platformVirtualMachinesJson = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().virtualMachines(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformVmTypesResult getPlatformSecurityGroupsResult = new GetPlatformVmTypesResult(request, platformVirtualMachinesJson);
request.getResult().onNext(getPlatformSecurityGroupsResult);
LOGGER.info("Query platform vmtypes types finished.");
} catch (Exception e) {
request.getResult().onNext(new GetPlatformVmTypesResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult in project cloudbreak by hortonworks.
the class CloudParameterService method getVmTypesV2.
public CloudVmTypes getVmTypesV2(Credential credential, String region, String variant, Map<String, String> filters) {
LOGGER.debug("Get platform vmtypes");
ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
GetPlatformVmTypesRequest getPlatformVmTypesRequest = new GetPlatformVmTypesRequest(cloudCredential, cloudCredential, variant, region, filters);
eventBus.notify(getPlatformVmTypesRequest.selector(), Event.wrap(getPlatformVmTypesRequest));
try {
GetPlatformVmTypesResult res = getPlatformVmTypesRequest.await();
LOGGER.info("Platform vmtypes result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform vmtypes", res.getErrorDetails());
throw new GetCloudParameterException("Failed to VM types for the cloud provider", res.getErrorDetails());
}
return res.getCloudVmTypes();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform vmtypes", e);
throw new OperationException(e);
}
}
Aggregations