use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.
the class ClusterCreationActions method clusterProxyRegistrationAction.
@Bean(name = "CLUSTER_PROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
return new AbstractStackCreationAction<>(ProvisionEvent.class) {
@Inject
private ClusterProxyEnablementService clusterProxyEnablementService;
@Override
protected void prepareExecution(ProvisionEvent payload, Map<Object, Object> variables) {
super.prepareExecution(payload, variables);
variables.put(PROVISION_TYPE, payload.getProvisionType());
}
@Override
protected void doExecute(StackCreationContext context, ProvisionEvent payload, Map<Object, Object> variables) {
if (clusterProxyEnablementService.isClusterProxyApplicable(context.getStack().cloudPlatform())) {
clusterCreationService.registeringToClusterProxy(context.getStack());
sendEvent(context);
} else {
ClusterProxyRegistrationSuccess clusterProxyRegistrationSuccess = new ClusterProxyRegistrationSuccess(payload.getResourceId());
sendEvent(context, clusterProxyRegistrationSuccess);
}
}
@Override
protected Selectable createRequest(StackCreationContext context) {
return new ClusterProxyRegistrationRequest(context.getStack().getId(), context.getStack().cloudPlatform());
}
};
}
use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess in project cloudbreak by hortonworks.
the class ClusterProxyRegistrationHandler method registerCluster.
private Selectable registerCluster(ClusterProxyRegistrationRequest request) {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
try {
if (!clusterProxyEnablementService.isClusterProxyApplicable(request.getCloudPlatform())) {
LOGGER.info("Cluster Proxy integration is DISABLED, skipping registering with Cluster Proxy service. Cluster CRN: {}", stack.getResourceCrn());
return new ClusterProxyRegistrationSuccess(request.getResourceId());
}
ConfigRegistrationResponse registerResponse = clusterProxyService.registerCluster(stack);
Cluster cluster = stack.getCluster();
if (cluster.hasGateway()) {
LOGGER.debug("Updating Gateway for cluster {} in environment {} with public key certificate retrieved from Cluster Proxy", cluster.getId(), stack.getEnvironmentCrn());
Gateway gateway = cluster.getGateway();
gateway.setTokenCert(registerResponse.getX509Unwrapped());
gatewayService.save(gateway);
}
return new ClusterProxyRegistrationSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Error occurred when registering cluster {} in environment {} to cluster proxy", stack.getCluster().getId(), stack.getEnvironmentCrn(), e);
return new ClusterProxyRegistrationFailed(request.getResourceId(), e);
}
}
Aggregations