Search in sources :

Example 1 with GetPlatformInstanceGroupParameterRequest

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

the class GetPlatformInstanceGroupParametersHandler method accept.

@Override
public void accept(Event<GetPlatformInstanceGroupParameterRequest> getPlatformInstanceGroupParameterRequestEvent) {
    LOGGER.info("Received event: {}", getPlatformInstanceGroupParameterRequestEvent);
    GetPlatformInstanceGroupParameterRequest request = getPlatformInstanceGroupParameterRequestEvent.getData();
    try {
        CloudPlatformVariant variant = new CloudPlatformVariant(platform(request.getExtendedCloudCredential().getCloudPlatform()), variant(request.getVariant()));
        Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses = cloudPlatformConnectors.get(variant).parameters().collectInstanceGroupParameters(request.getInstanceGroupParameterRequest());
        GetPlatformInstanceGroupParameterResult getPlatformInstanceGroupParameterResult = new GetPlatformInstanceGroupParameterResult(request, instanceGroupParameterResponses);
        request.getResult().onNext(getPlatformInstanceGroupParameterResult);
        LOGGER.info("Query platform instance group parameters finished.");
    } catch (Exception e) {
        request.getResult().onNext(new GetPlatformInstanceGroupParameterResult(e.getMessage(), e, request));
    }
}
Also used : GetPlatformInstanceGroupParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest) GetPlatformInstanceGroupParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult) InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)

Example 2 with GetPlatformInstanceGroupParameterRequest

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

the class CloudParameterService method getInstanceGroupParameters.

public Map<String, InstanceGroupParameterResponse> getInstanceGroupParameters(Credential credential, Set<InstanceGroupParameterRequest> instanceGroups) {
    LOGGER.debug("Get platform getInstanceGroupParameters");
    ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
    GetPlatformInstanceGroupParameterRequest getPlatformInstanceGroupParameterRequest = new GetPlatformInstanceGroupParameterRequest(cloudCredential, cloudCredential, instanceGroups, null);
    eventBus.notify(getPlatformInstanceGroupParameterRequest.selector(), Event.wrap(getPlatformInstanceGroupParameterRequest));
    try {
        GetPlatformInstanceGroupParameterResult res = getPlatformInstanceGroupParameterRequest.await();
        LOGGER.info("Platform instanceGroupParameterResult result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform instanceGroupParameterResult", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to instance group parameters for the cloud provider", res.getErrorDetails());
        }
        return res.getInstanceGroupParameterResponses();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform publicIpPools", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformInstanceGroupParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformInstanceGroupParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

GetPlatformInstanceGroupParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest)2 GetPlatformInstanceGroupParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 InstanceGroupParameterResponse (com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse)1 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)1