Search in sources :

Example 61 with CloudContext

use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.

the class GetTlsInfoHandler method accept.

@Override
public void accept(Event<GetTlsInfoRequest> getTlsInfoRequestEvent) {
    LOGGER.info("Received event: {}", getTlsInfoRequestEvent);
    GetTlsInfoRequest<?> tlsInfoRequest = getTlsInfoRequestEvent.getData();
    try {
        CloudContext cloudContext = tlsInfoRequest.getCloudContext();
        CloudCredential cloudCredential = tlsInfoRequest.getCloudCredential();
        CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
        CloudStack cloudStack = tlsInfoRequest.getCloudStack();
        AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, cloudCredential);
        TlsInfo tlsInfo = connector.resources().getTlsInfo(ac, cloudStack);
        GetTlsInfoResult getTlsInfoResult = new GetTlsInfoResult(tlsInfoRequest, tlsInfo);
        tlsInfoRequest.getResult().onNext(getTlsInfoResult);
        eventBus.notify(getTlsInfoResult.selector(), new Event<>(getTlsInfoRequestEvent.getHeaders(), getTlsInfoResult));
        LOGGER.info("GetTlsInfoHandler finished.");
    } catch (RuntimeException e) {
        String errorMsg = "Failed to get Tls info from cloud connector!";
        LOGGER.error(errorMsg, e);
        GetTlsInfoResult failure = new GetTlsInfoResult(errorMsg, e, tlsInfoRequest);
        tlsInfoRequest.getResult().onNext(failure);
        eventBus.notify(failure.selector(), new Event<>(getTlsInfoRequestEvent.getHeaders(), failure));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) TlsInfo(com.sequenceiq.cloudbreak.cloud.model.TlsInfo) GetTlsInfoResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult) Event(reactor.bus.Event) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack)

Example 62 with CloudContext

use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.

the class InstanceStateHandler method accept.

@Override
public void accept(Event<GetInstancesStateRequest> event) {
    LOGGER.info("Received event: {}", event);
    GetInstancesStateRequest request = event.getData();
    CloudContext cloudContext = request.getCloudContext();
    GetInstancesStateResult result;
    try {
        List<CloudVmInstanceStatus> instanceStatuses = instanceStateQuery.getCloudVmInstanceStatuses(request.getCloudCredential(), cloudContext, request.getInstances());
        result = new GetInstancesStateResult(request, instanceStatuses);
    } catch (RuntimeException e) {
        result = new GetInstancesStateResult("Instance state synchronizing failed", e, request);
    }
    request.getResult().onNext(result);
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : GetInstancesStateRequest(com.sequenceiq.cloudbreak.cloud.event.resource.GetInstancesStateRequest) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) GetInstancesStateResult(com.sequenceiq.cloudbreak.cloud.event.resource.GetInstancesStateResult)

Example 63 with CloudContext

use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.

the class InteractiveLoginHandler method accept.

@Override
public void accept(Event<InteractiveLoginRequest> interactiveLoginRequestEvent) {
    LOGGER.info("Received event: {}", interactiveLoginRequestEvent);
    InteractiveLoginRequest request = interactiveLoginRequestEvent.getData();
    CloudContext cloudContext = request.getCloudContext();
    try {
        CloudConnector connector = cloudPlatformConnectors.getDefault(cloudContext.getPlatform());
        Map<String, String> parameters = connector.credentials().interactiveLogin(cloudContext, request.getExtendedCloudCredential(), credentialNotifier);
        InteractiveLoginResult interactiveLoginResult = new InteractiveLoginResult(request, parameters);
        request.getResult().onNext(interactiveLoginResult);
        LOGGER.info("Interactive login request successfully processed");
    } catch (RuntimeException e) {
        request.getResult().onNext(new InteractiveLoginResult(e.getMessage(), e, request));
    }
}
Also used : InteractiveLoginResult(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult) InteractiveLoginRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext)

Example 64 with CloudContext

use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.

the class AbstractInstanceConnector method stop.

@Override
public List<CloudVmInstanceStatus> stop(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) {
    CloudContext cloudContext = ac.getCloudContext();
    Platform platform = cloudContext.getPlatform();
    // context
    ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, ac, null, resources, false);
    // compute
    return computeResourceService.stopInstances(context, ac, resources, vms);
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)

Example 65 with CloudContext

use of com.sequenceiq.cloudbreak.cloud.context.CloudContext in project cloudbreak by hortonworks.

the class AbstractResourceConnector method terminate.

@Override
public List<CloudResourceStatus> terminate(AuthenticatedContext auth, CloudStack stack, List<CloudResource> cloudResources) throws Exception {
    CloudContext cloudContext = auth.getCloudContext();
    Platform platform = cloudContext.getPlatform();
    // context
    ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), cloudResources, false);
    // compute
    List<CloudResourceStatus> cloudResourceStatuses = computeResourceService.deleteResources(context, auth, cloudResources, false);
    // group
    List<CloudResourceStatus> groupStatuses = groupResourceService.deleteResources(context, auth, cloudResources, stack.getNetwork(), false);
    cloudResourceStatuses.addAll(groupStatuses);
    // network
    List<CloudResourceStatus> networkStatuses = networkResourceService.deleteResources(context, auth, cloudResources, stack.getNetwork(), false);
    cloudResourceStatuses.addAll(networkStatuses);
    return cloudResourceStatuses;
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)

Aggregations

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)100 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)43 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)34 Test (org.junit.Test)34 Group (com.sequenceiq.cloudbreak.cloud.model.Group)33 HashMap (java.util.HashMap)33 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)32 Location (com.sequenceiq.cloudbreak.cloud.model.Location)31 Network (com.sequenceiq.cloudbreak.cloud.model.Network)31 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)31 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)25 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)20 AzureCredentialView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView)19 Matchers.containsString (org.hamcrest.Matchers.containsString)18 AzureStackView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView)17 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)16 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)15 ArrayList (java.util.ArrayList)15 DescribeSubnetsResult (com.amazonaws.services.ec2.model.DescribeSubnetsResult)14 DescribeVpcsResult (com.amazonaws.services.ec2.model.DescribeVpcsResult)14