Search in sources :

Example 36 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackCreationActions method getTlsInfoAction.

@Bean(name = "GET_TLS_INFO_STATE")
public Action<?, ?> getTlsInfoAction() {
    return new AbstractStackCreationAction<GetTlsInfoResult>(GetTlsInfoResult.class) {

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

        @Override
        protected Selectable createRequest(StackContext context) {
            InstanceMetaData gatewayMetaData = context.getStack().getPrimaryGatewayInstance();
            CloudInstance gatewayInstance = metadataConverter.convert(gatewayMetaData);
            return new GetSSHFingerprintsRequest<GetSSHFingerprintsResult>(context.getCloudContext(), context.getCloudCredential(), gatewayInstance);
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) GetSSHFingerprintsRequest(com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) GetTlsInfoResult(com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.Stack) Bean(org.springframework.context.annotation.Bean)

Example 37 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackCreationService method saveTlsInfo.

public Stack saveTlsInfo(StackContext context, TlsInfo tlsInfo) {
    boolean usePrivateIpToTls = tlsInfo.usePrivateIpToTls();
    Stack stack = context.getStack();
    if (usePrivateIpToTls) {
        SecurityConfig securityConfig = stack.getSecurityConfig();
        securityConfig.setUsePrivateIpToTls(usePrivateIpToTls);
        stackUpdater.updateStackSecurityConfig(stack, securityConfig);
        stack = stackService.getByIdWithLists(stack.getId());
        LOGGER.info("Update Stack and it's SecurityConfig to use private ip when TLS is built.");
    }
    return stack;
}
Also used : SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 38 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class StackCreationService method checkImage.

public CheckImageResult checkImage(StackContext context) {
    try {
        Stack stack = context.getStack();
        Image image = imageService.getImage(stack.getId());
        CheckImageRequest<CheckImageResult> checkImageRequest = new CheckImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStackConverter.convert(stack), image);
        LOGGER.info("Triggering event: {}", checkImageRequest);
        eventBus.notify(checkImageRequest.selector(), eventFactory.createEvent(checkImageRequest));
        CheckImageResult result = checkImageRequest.await();
        sendNotification(result, stack);
        LOGGER.info("Result: {}", result);
        return result;
    } catch (InterruptedException e) {
        LOGGER.error("Error while executing check image", e);
        throw new OperationException(e);
    } catch (CloudbreakImageNotFoundException e) {
        throw new CloudbreakServiceException(e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) CheckImageResult(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageResult) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) OperationException(com.sequenceiq.cloudbreak.service.stack.connector.OperationException) Stack(com.sequenceiq.cloudbreak.domain.Stack) CheckImageRequest(com.sequenceiq.cloudbreak.cloud.event.setup.CheckImageRequest)

Example 39 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class DisableOnGCPRestartAction method restart.

@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
    Payload stackPayload = (Payload) payload;
    Stack stack = stackService.getById(stackPayload.getStackId());
    if (stack.getPlatformVariant().equals(GCP)) {
        flowLogService.terminate(stackPayload.getStackId(), flowId);
    } else {
        restart(flowId, flowChainId, event, payload, stack);
    }
}
Also used : Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 40 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class FillInMemoryStateStoreRestartAction method restart.

@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
    Payload stackPayload = (Payload) payload;
    Stack stack = stackService.getByIdWithLists(stackPayload.getStackId());
    restart(flowId, flowChainId, event, payload, stack);
}
Also used : Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14