Search in sources :

Example 1 with GetPlatformPrivateDnsZonesRequest

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

the class CloudParameterService method getPrivateDnsZones.

@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudPrivateDnsZones getPrivateDnsZones(ExtendedCloudCredential cloudCredential, String platformVariant, Map<String, String> filters) {
    LOGGER.debug("Get platform private DNS zones for credential: [{}]", cloudCredential.getName());
    GetPlatformPrivateDnsZonesRequest request = new GetPlatformPrivateDnsZonesRequest(cloudCredential, cloudCredential, platformVariant, null);
    eventBus.notify(request.selector(), Event.wrap(request));
    try {
        GetPlatformPrivateDnsZonesResult result = request.await();
        LOGGER.debug("Platform PrivateDnsZonesResult result: {}", result);
        if (result.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.debug("Failed to get platform PrivateDnsZonesResult", result.getErrorDetails());
            throw new GetCloudParameterException(String.format("Failed to get private dns zones for the cloud provider: %s. %s", result.getStatusReason(), getCauseMessages(result.getErrorDetails())), result.getErrorDetails());
        }
        return result.getPrivateDnsZones();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform PrivateDnsZonesResult", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformPrivateDnsZonesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesResult) GetPlatformPrivateDnsZonesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesRequest) OperationException(com.sequenceiq.cloudbreak.service.OperationException) Retryable(org.springframework.retry.annotation.Retryable)

Example 2 with GetPlatformPrivateDnsZonesRequest

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

the class GetPlatformPrivateDnsZonesHandler method accept.

@Override
public void accept(Event<GetPlatformPrivateDnsZonesRequest> event) {
    LOGGER.debug("Received event to retrieve private DNS zones: {}", event);
    GetPlatformPrivateDnsZonesRequest request = event.getData();
    try {
        CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
        CloudPrivateDnsZones privateDnsZones = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().privateDnsZones(request.getExtendedCloudCredential(), request.getFilters());
        GetPlatformPrivateDnsZonesResult result = new GetPlatformPrivateDnsZonesResult(request.getResourceId(), privateDnsZones);
        request.getResult().onNext(result);
        LOGGER.debug("Query platform private DNS zones finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetPlatformPrivateDnsZonesResult(e.getMessage(), e, request.getResourceId()));
    }
}
Also used : GetPlatformPrivateDnsZonesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesResult) GetPlatformPrivateDnsZonesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesRequest) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) CloudPrivateDnsZones(com.sequenceiq.cloudbreak.cloud.model.dns.CloudPrivateDnsZones)

Aggregations

GetPlatformPrivateDnsZonesRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesRequest)2 GetPlatformPrivateDnsZonesResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformPrivateDnsZonesResult)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudPrivateDnsZones (com.sequenceiq.cloudbreak.cloud.model.dns.CloudPrivateDnsZones)1 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 Retryable (org.springframework.retry.annotation.Retryable)1