Search in sources :

Example 1 with GetTlsInfoResult

use of com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult 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 2 with GetTlsInfoResult

use of com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult 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)

Aggregations

GetTlsInfoResult (com.sequenceiq.cloudbreak.cloud.event.instance.GetTlsInfoResult)2 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)2 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 GetSSHFingerprintsRequest (com.sequenceiq.cloudbreak.cloud.event.instance.GetSSHFingerprintsRequest)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 TlsInfo (com.sequenceiq.cloudbreak.cloud.model.TlsInfo)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1 Event (reactor.bus.Event)1