Search in sources :

Example 11 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.

the class ServiceProviderMetadataAdapter method collectMetadata.

public List<CloudVmMetaDataStatus> collectMetadata(Stack stack) {
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
    CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
    List<CloudInstance> cloudInstances = cloudStackConverter.buildInstances(stack);
    List<CloudResource> cloudResources = cloudResourceConverter.convert(stack.getResources());
    CollectMetadataRequest cmr = new CollectMetadataRequest(cloudContext, cloudCredential, cloudResources, cloudInstances);
    LOGGER.info("Triggering event: {}", cmr);
    eventBus.notify(CloudPlatformRequest.selector(CollectMetadataRequest.class), eventFactory.createEvent(cmr));
    try {
        CollectMetadataResult res = cmr.await();
        LOGGER.info("Result: {}", res);
        if (res.getErrorDetails() != null) {
            LOGGER.error("Failed to collect metadata", res.getErrorDetails());
            return Collections.emptyList();
        }
        return res.getResults();
    } catch (InterruptedException e) {
        LOGGER.error(format("Error while executing collectMetadata, stack: %s", cloudContext), e);
        throw new OperationException(e);
    }
}
Also used : CollectMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CollectMetadataResult(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 12 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getPlatformVariants.

public PlatformVariants getPlatformVariants() {
    LOGGER.debug("Get platform variants");
    GetPlatformVariantsRequest getPlatformVariantsRequest = new GetPlatformVariantsRequest();
    eventBus.notify(getPlatformVariantsRequest.selector(), eventFactory.createEvent(getPlatformVariantsRequest));
    try {
        GetPlatformVariantsResult res = getPlatformVariantsRequest.await();
        LOGGER.info("Platform variants result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform variants", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformVariants();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform variants", e);
        throw new OperationException(e);
    }
}
Also used : GetPlatformVariantsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVariantsResult) GetPlatformVariantsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformVariantsRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 13 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getRecommendation.

public VmRecommendations getRecommendation(String platform) {
    LOGGER.debug("Get platform vm recommendation");
    GetVirtualMachineRecommendtaionRequest getVirtualMachineRecommendtaionRequest = new GetVirtualMachineRecommendtaionRequest(platform);
    eventBus.notify(getVirtualMachineRecommendtaionRequest.selector(), eventFactory.createEvent(getVirtualMachineRecommendtaionRequest));
    try {
        GetVirtualMachineRecommendationResponse res = getVirtualMachineRecommendtaionRequest.await();
        LOGGER.info("Platform vm recommendation result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform vm recommendation", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getRecommendations();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform vm recommendation", e);
        throw new OperationException(e);
    }
}
Also used : GetVirtualMachineRecommendtaionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest) GetVirtualMachineRecommendationResponse(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 14 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getCloudAccessConfigs.

public CloudAccessConfigs getCloudAccessConfigs(Credential credential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform accessConfigs");
    ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
    GetPlatformCloudAccessConfigsRequest getPlatformCloudAccessConfigsRequest = new GetPlatformCloudAccessConfigsRequest(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformCloudAccessConfigsRequest.selector(), Event.wrap(getPlatformCloudAccessConfigsRequest));
    try {
        GetPlatformCloudAccessConfigsResult res = getPlatformCloudAccessConfigsRequest.await();
        LOGGER.info("Platform accessConfigs result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform accessConfigs", res.getErrorDetails());
            throw new GetCloudParameterException("Failed to get access configs for the cloud provider", res.getErrorDetails());
        }
        return res.getCloudAccessConfigs();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform accessConfigs", e);
        throw new OperationException(e);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformCloudAccessConfigsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsResult) GetPlatformCloudAccessConfigsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsRequest) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 15 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.

the class CloudParameterService method getDiskTypes.

public PlatformDisks getDiskTypes() {
    LOGGER.debug("Get platform disktypes");
    GetDiskTypesRequest getDiskTypesRequest = new GetDiskTypesRequest();
    eventBus.notify(getDiskTypesRequest.selector(), eventFactory.createEvent(getDiskTypesRequest));
    try {
        GetDiskTypesResult res = getDiskTypesRequest.await();
        LOGGER.info("Platform disk types result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform disk types", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getPlatformDisks();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform disk types", e);
        throw new OperationException(e);
    }
}
Also used : GetDiskTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest) GetDiskTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)29 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)12 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)11 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)9 Location (com.sequenceiq.cloudbreak.cloud.model.Location)8 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)3 CheckImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)2 CheckImageResult (com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult)2 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)2 CredentialVerificationRequest (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationRequest)1 CredentialVerificationResult (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationResult)1 InteractiveLoginRequest (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest)1 InteractiveLoginResult (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult)1 CollectMetadataRequest (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest)1 CollectMetadataResult (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataResult)1 CheckPlatformVariantRequest (com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest)1