Search in sources :

Example 1 with ExtendedCloudCredential

use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.

the class ExtendedCloudCredentialToCredentialConverter method convert.

public Credential convert(ExtendedCloudCredential extendedCloudCredential) {
    Credential credential = new Credential();
    credential.setId(extendedCloudCredential.getId());
    credential.setName(extendedCloudCredential.getName());
    credential.setDescription(extendedCloudCredential.getDescription());
    credential.setAccount(extendedCloudCredential.getAccount());
    credential.setOwner(extendedCloudCredential.getOwner());
    credential.setCloudPlatform(extendedCloudCredential.getCloudPlatform());
    try {
        Json json = new Json(extendedCloudCredential.getParameters());
        credential.setAttributes(json);
    } catch (JsonProcessingException e) {
        throw new IllegalStateException(e);
    }
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 2 with ExtendedCloudCredential

use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.

the class ServiceProviderCredentialAdapter method interactiveLogin.

public Map<String, String> interactiveLogin(Credential credential) {
    CloudContext cloudContext = new CloudContext(credential.getId(), credential.getName(), credential.cloudPlatform(), credential.getOwner());
    ExtendedCloudCredential cloudCredential = extendedCloudCredentialConverter.convert(credential);
    InteractiveLoginRequest request = new InteractiveLoginRequest(cloudContext, cloudCredential);
    LOGGER.info("Triggering event: {}", request);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    try {
        InteractiveLoginResult res = request.await();
        String message = "Interactive login Failed: ";
        LOGGER.info("Result: {}", res);
        if (res.getStatus() != EventStatus.OK) {
            LOGGER.error(message, res.getErrorDetails());
            throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
        }
        return res.getParameters();
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing credential verification", e);
        throw new OperationException(e);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) InteractiveLoginResult(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult) InteractiveLoginRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Example 3 with ExtendedCloudCredential

use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential 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 4 with ExtendedCloudCredential

use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential 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 5 with ExtendedCloudCredential

use of com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential in project cloudbreak by hortonworks.

the class CloudParameterService method getRegionsV2.

public CloudRegions getRegionsV2(Credential credential, String region, String variant, Map<String, String> filters) {
    LOGGER.debug("Get platform regions");
    ExtendedCloudCredential cloudCredential = credentialToExtendedCloudCredentialConverter.convert(credential);
    GetPlatformRegionsRequestV2 getPlatformRegionsRequest = new GetPlatformRegionsRequestV2(cloudCredential, cloudCredential, variant, region, filters);
    eventBus.notify(getPlatformRegionsRequest.selector(), Event.wrap(getPlatformRegionsRequest));
    try {
        GetPlatformRegionsResultV2 res = getPlatformRegionsRequest.await();
        LOGGER.info("Platform regions result: {}", res);
        if (res.getStatus().equals(EventStatus.FAILED)) {
            throw new GetCloudParameterException("Failed to get regions from the cloud provider due to network issues or invalid credential", res.getErrorDetails());
        }
        return res.getCloudRegions();
    } catch (InterruptedException e) {
        LOGGER.error("Error while getting the platform regions", e);
        throw new OperationException(e);
    }
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) GetPlatformRegionsResultV2(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsResultV2) GetPlatformRegionsRequestV2(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformRegionsRequestV2) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException)

Aggregations

ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)13 OperationException (com.sequenceiq.cloudbreak.service.stack.connector.OperationException)10 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ServicePrincipalInner (com.microsoft.azure.management.graphrbac.implementation.ServicePrincipalInner)1 AzureCredentialView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 InteractiveCredentialCreationRequest (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveCredentialCreationRequest)1 InteractiveLoginRequest (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest)1 InteractiveLoginResult (com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult)1 GetPlatformCloudAccessConfigsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsRequest)1 GetPlatformCloudAccessConfigsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudAccessConfigsResult)1 GetPlatformCloudGatewaysRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysRequest)1 GetPlatformCloudGatewaysResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudGatewaysResult)1 GetPlatformCloudIpPoolsRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsRequest)1 GetPlatformCloudIpPoolsResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformCloudIpPoolsResult)1 GetPlatformInstanceGroupParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest)1 GetPlatformInstanceGroupParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult)1