Search in sources :

Example 1 with GetPlatformVmTypesResult

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));
    }
}
Also used : GetPlatformVmTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult) CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) GetPlatformVmTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesRequest)

Example 2 with GetPlatformVmTypesResult

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);
    }
}
Also used : GetPlatformVmTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformVmTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

GetPlatformVmTypesRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesRequest)2 GetPlatformVmTypesResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVmTypesResult)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1