Search in sources :

Example 1 with KeytabConfigurationSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationSuccess in project cloudbreak by hortonworks.

the class ClusterUpscaleActions method configureKeytabsAction.

@Bean(name = "RECONFIGURE_KEYTABS_STATE")
public Action<?, ?> configureKeytabsAction() {
    return new AbstractClusterUpscaleAction<>(UploadUpscaleRecipesResult.class) {

        @Override
        protected void doExecute(ClusterUpscaleContext context, UploadUpscaleRecipesResult payload, Map<Object, Object> variables) {
            if (context.isSinglePrimaryGateway() && ClusterManagerType.CLOUDERA_MANAGER.equals(context.getClusterManagerType())) {
                KeytabConfigurationRequest keytabConfigurationRequest = new KeytabConfigurationRequest(context.getStackId());
                sendEvent(context, keytabConfigurationRequest.selector(), keytabConfigurationRequest);
            } else {
                KeytabConfigurationSuccess keytabConfigurationSuccess = new KeytabConfigurationSuccess(context.getStackId());
                sendEvent(context, keytabConfigurationSuccess.selector(), keytabConfigurationSuccess);
            }
        }
    };
}
Also used : KeytabConfigurationRequest(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationRequest) KeytabConfigurationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationSuccess) Map(java.util.Map) HashMap(java.util.HashMap) UploadUpscaleRecipesResult(com.sequenceiq.cloudbreak.reactor.api.event.recipe.UploadUpscaleRecipesResult) Bean(org.springframework.context.annotation.Bean)

Example 2 with KeytabConfigurationSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationSuccess in project cloudbreak by hortonworks.

the class KeytabConfigurationHandler method accept.

@Override
public void accept(Event<KeytabConfigurationRequest> keytabConfigurationRequestEvent) {
    Long stackId = keytabConfigurationRequestEvent.getData().getResourceId();
    Selectable response;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(stackId);
        Optional<KerberosConfig> kerberosConfigOptional = kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName());
        boolean childEnvironment = environmentConfigProvider.isChildEnvironment(stack.getEnvironmentCrn());
        if (kerberosDetailService.keytabsShouldBeUpdated(stack.cloudPlatform(), childEnvironment, kerberosConfigOptional)) {
            GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
            ServiceKeytabResponse serviceKeytabResponse = keytabProvider.getServiceKeytabResponse(stack, primaryGatewayConfig);
            KeytabModel keytabModel = buildKeytabModel(serviceKeytabResponse);
            hostOrchestrator.uploadKeytabs(List.of(primaryGatewayConfig), Set.of(keytabModel), ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, stack.getCluster().getId()));
        }
        response = new KeytabConfigurationSuccess(stackId);
    } catch (Exception e) {
        LOGGER.info("Error during keytab configuration, stackId: " + stackId, e);
        KeytabConfigurationException configurationException = new KeytabConfigurationException("Keytab generation failed with: " + e.getMessage(), e);
        response = new KeytabConfigurationFailed(stackId, configurationException);
    }
    eventBus.notify(response.selector(), new Event<>(keytabConfigurationRequestEvent.getHeaders(), response));
}
Also used : KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) KeytabConfigurationException(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) KeytabModel(com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel) KeytabConfigurationFailed(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) KeytabConfigurationException(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationException) ServiceKeytabResponse(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabResponse) KeytabConfigurationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationSuccess) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

KeytabConfigurationSuccess (com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationSuccess)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 KerberosConfig (com.sequenceiq.cloudbreak.dto.KerberosConfig)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 KeytabModel (com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel)1 KeytabConfigurationException (com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationException)1 KeytabConfigurationFailed (com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationFailed)1 KeytabConfigurationRequest (com.sequenceiq.cloudbreak.reactor.api.event.kerberos.KeytabConfigurationRequest)1 UploadUpscaleRecipesResult (com.sequenceiq.cloudbreak.reactor.api.event.recipe.UploadUpscaleRecipesResult)1 ServiceKeytabResponse (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabResponse)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1