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);
}
};
}
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));
}
}
Aggregations