Search in sources :

Example 1 with GetPlatformNetworksResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult in project cloudbreak by hortonworks.

the class CloudParameterService method getCloudNetworks.

public CloudNetworks getCloudNetworks(Credential credential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform cloudnetworks");
    ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
    GetPlatformNetworksRequest getPlatformNetworksRequest = new GetPlatformNetworksRequest(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformNetworksRequest.selector(), eventFactory.createEvent(getPlatformNetworksRequest));
    try {
        GetPlatformNetworksResult res = getPlatformNetworksRequest.await();
        LOGGER.info("Platform networks types result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform networks", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get networks for the cloud provider", res.getErrorDetails());
        }
        return res.getCloudNetworks();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform networks", e);
        throw new OperationException(e);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformNetworksResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult) GetPlatformNetworksRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 2 with GetPlatformNetworksResult

use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult in project cloudbreak by hortonworks.

the class GetPlatformNetworksHandler method accept.

@Override
public void accept(Event<GetPlatformNetworksRequest> getPlatformNetworksRequest) {
    LOGGER.info("Received event: {}", getPlatformNetworksRequest);
    GetPlatformNetworksRequest request = getPlatformNetworksRequest.getData();
    try {
        CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
        CloudNetworks networks = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().networks(request.getCloudCredential(), Region.region(request.getRegion()), request.getFilters());
        GetPlatformNetworksResult getPlatformNetworksResult = new GetPlatformNetworksResult(request, networks);
        request.getResult().onNext(getPlatformNetworksResult);
        LOGGER.info("Query platform networks types finished.");
    } catch (Exception e) {
        request.getResult().onNext(new GetPlatformNetworksResult(e.getMessage(), e, request));
    }
}
Also used : GetPlatformNetworksResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult) GetPlatformNetworksRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksRequest) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)

Aggregations

GetPlatformNetworksRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksRequest)2 GetPlatformNetworksResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNetworksResult)2 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1