Search in sources :

Example 16 with OperationException

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

the class CloudParameterService method getRegions.

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

Example 17 with OperationException

use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException 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)

Example 18 with OperationException

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

the class ServiceProviderConnectorAdapter method removeInstances.

public Set<String> removeInstances(Stack stack, Set<String> instanceIds, String instanceGroup) {
    LOGGER.debug("Assembling downscale stack event for 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<CloudResource> resources = cloudResourceConverter.convert(stack.getResources());
    List<CloudInstance> instances = new ArrayList<>();
    InstanceGroup group = stack.getInstanceGroupByInstanceGroupName(instanceGroup);
    for (InstanceMetaData metaData : group.getAllInstanceMetaData()) {
        if (instanceIds.contains(metaData.getInstanceId())) {
            CloudInstance cloudInstance = metadataConverter.convert(metaData);
            instances.add(cloudInstance);
        }
    }
    CloudStack cloudStack = cloudStackConverter.convertForDownscale(stack, instanceIds);
    DownscaleStackRequest downscaleRequest = new DownscaleStackRequest(cloudContext, cloudCredential, cloudStack, resources, instances);
    LOGGER.info("Triggering downscale stack event: {}", downscaleRequest);
    eventBus.notify(downscaleRequest.selector(), eventFactory.createEvent(downscaleRequest));
    try {
        DownscaleStackResult res = downscaleRequest.await();
        LOGGER.info("Downscale stack result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to downscale the stack", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return instanceIds;
    } catch (InterruptedException e) {
        LOGGER.error("Error while downscaling the stack", e);
        throw new OperationException(e);
    }
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ArrayList(java.util.ArrayList) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) DownscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult) DownscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackRequest) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 19 with OperationException

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

the class ServiceProviderConnectorAdapter method checkAndGetPlatformVariant.

public Variant checkAndGetPlatformVariant(Stack stack) {
    LOGGER.debug("Get platform variant for: {}", 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());
    CheckPlatformVariantRequest checkPlatformVariantRequest = new CheckPlatformVariantRequest(cloudContext, cloudCredential);
    eventBus.notify(checkPlatformVariantRequest.selector(), eventFactory.createEvent(checkPlatformVariantRequest));
    try {
        CheckPlatformVariantResult res = checkPlatformVariantRequest.await();
        LOGGER.info("Platform variant result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            LOGGER.error("Failed to get platform variant", res.getErrorDetails());
            throw new OperationException(res.getErrorDetails());
        }
        return res.getDefaultPlatformVariant();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform variant: " + cloudContext, e);
        throw new OperationException(e);
    }
}
Also used : CheckPlatformVariantRequest(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CheckPlatformVariantResult(com.sequenceiq.cloudbreak.cloud.event.platform.CheckPlatformVariantResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 20 with OperationException

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

the class ServiceProviderMetadataAdapter method getState.

public InstanceSyncState getState(Stack stack, InstanceGroup instanceGroup, String instanceId) {
    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());
    InstanceGroup ig = stack.getInstanceGroupByInstanceGroupName(instanceGroup.getGroupName());
    CloudInstance instance = null;
    for (InstanceMetaData metaData : ig.getAllInstanceMetaData()) {
        if (instanceId.equalsIgnoreCase(metaData.getInstanceId())) {
            instance = metadataConverter.convert(metaData);
            break;
        }
    }
    if (instance != null) {
        GetInstancesStateRequest<GetInstancesStateResult> stateRequest = new GetInstancesStateRequest<>(cloudContext, cloudCredential, Collections.singletonList(instance));
        LOGGER.info("Triggering event: {}", stateRequest);
        eventBus.notify(stateRequest.selector(), eventFactory.createEvent(stateRequest));
        try {
            GetInstancesStateResult res = stateRequest.await();
            LOGGER.info("Result: {}", res);
            if (res.isFailed()) {
                LOGGER.error("Failed to retrieve instance state", res.getErrorDetails());
                throw new OperationException(res.getErrorDetails());
            }
            return transform(res.getStatuses().get(0).getStatus());
        } catch (InterruptedException e) {
            LOGGER.error(format("Error while retrieving instance state of: %s", cloudContext), e);
            throw new OperationException(e);
        }
    } else {
        return InstanceSyncState.DELETED;
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) GetInstancesStateRequest(com.sequenceiq.cloudbreak.cloud.event.resource.GetInstancesStateRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) GetInstancesStateResult(com.sequenceiq.cloudbreak.cloud.event.resource.GetInstancesStateResult) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Location(com.sequenceiq.cloudbreak.cloud.model.Location) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

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