Search in sources :

Example 1 with LaunchStackResult

use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult in project cloudbreak by hortonworks.

the class LaunchStackComponentTest method testLaunchStack.

@Test
public void testLaunchStack() {
    LaunchStackResult lsr = sendCloudRequest();
    List<CloudResourceStatus> r = lsr.getResults();
    assertEquals(ResourceStatus.CREATED, r.get(0).getStatus());
    assertNull(lsr.getErrorDetails());
}
Also used : CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) LaunchStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult) Test(org.junit.Test)

Example 2 with LaunchStackResult

use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult in project cloudbreak by hortonworks.

the class StackCreationActions method provisioningFinishedAction.

@Bean(name = "PROVISIONING_FINISHED_STATE")
public Action<?, ?> provisioningFinishedAction() {
    return new AbstractStackCreationAction<LaunchStackResult>(LaunchStackResult.class) {

        @Override
        protected void doExecute(StackContext context, LaunchStackResult payload, Map<Object, Object> variables) {
            Stack stack = stackCreationService.provisioningFinished(context, payload, variables);
            StackContext newContext = new StackContext(context.getFlowId(), stack, context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
            sendEvent(newContext);
        }

        @Override
        protected Selectable createRequest(StackContext context) {
            List<CloudInstance> cloudInstances = cloudStackConverter.buildInstances(context.getStack());
            List<CloudResource> cloudResources = cloudResourceConverter.convert(context.getStack().getResources());
            return new CollectMetadataRequest(context.getCloudContext(), context.getCloudCredential(), cloudResources, cloudInstances);
        }
    };
}
Also used : CollectMetadataRequest(com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) LaunchStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.Stack) Bean(org.springframework.context.annotation.Bean)

Example 3 with LaunchStackResult

use of com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult in project cloudbreak by hortonworks.

the class LaunchStackHandler method accept.

@Override
public void accept(Event<LaunchStackRequest> launchStackRequestEvent) {
    LOGGER.info("Received event: {}", launchStackRequestEvent);
    LaunchStackRequest request = launchStackRequestEvent.getData();
    CloudContext cloudContext = request.getCloudContext();
    try {
        CloudConnector connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
        AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
        List<CloudResourceStatus> resourceStatus = connector.resources().launch(ac, request.getCloudStack(), persistenceNotifier, request.getAdjustmentType(), request.getThreshold());
        List<CloudResource> resources = ResourceLists.transform(resourceStatus);
        PollTask<ResourcesStatePollerResult> task = statusCheckFactory.newPollResourcesStateTask(ac, resources, true);
        ResourcesStatePollerResult statePollerResult = ResourcesStatePollerResults.build(cloudContext, resourceStatus);
        if (!task.completed(statePollerResult)) {
            statePollerResult = syncPollingScheduler.schedule(task);
        }
        LaunchStackResult result = ResourcesStatePollerResults.transformToLaunchStackResult(request, statePollerResult);
        request.getResult().onNext(result);
        eventBus.notify(result.selector(), new Event<>(launchStackRequestEvent.getHeaders(), result));
        LOGGER.info("Launching the stack successfully finished for {}", cloudContext);
    } catch (Exception e) {
        LaunchStackResult failure = new LaunchStackResult(e, request);
        LOGGER.error("Error during launching the stack:", e);
        request.getResult().onNext(failure);
        eventBus.notify(failure.selector(), new Event<>(launchStackRequestEvent.getHeaders(), failure));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) LaunchStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) Event(reactor.bus.Event) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ResourcesStatePollerResult(com.sequenceiq.cloudbreak.cloud.task.ResourcesStatePollerResult) LaunchStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackRequest)

Aggregations

LaunchStackResult (com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackResult)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)2 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CollectMetadataRequest (com.sequenceiq.cloudbreak.cloud.event.instance.CollectMetadataRequest)1 LaunchStackRequest (com.sequenceiq.cloudbreak.cloud.event.resource.LaunchStackRequest)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 ResourcesStatePollerResult (com.sequenceiq.cloudbreak.cloud.task.ResourcesStatePollerResult)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 Map (java.util.Map)1 Test (org.junit.Test)1 Bean (org.springframework.context.annotation.Bean)1 Event (reactor.bus.Event)1