Search in sources :

Example 1 with ClusterProxyRegistrationFailed

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);
    }
}
Also used : ClusterProxyRegistrationFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationFailed) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ConfigRegistrationResponse(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClusterProxyRegistrationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)1 ClusterProxyRegistrationFailed (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationFailed)1 ClusterProxyRegistrationSuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyRegistrationSuccess)1