use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationFailed 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