use of com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel 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));
}
use of com.sequenceiq.cloudbreak.orchestrator.model.KeytabModel in project cloudbreak by hortonworks.
the class SaltOrchestrator method uploadKeytabs.
@Override
public void uploadKeytabs(List<GatewayConfig> allGatewayConfigs, Set<KeytabModel> keytabModels, ExitCriteriaModel exitModel) throws CloudbreakOrchestratorFailedException {
GatewayConfig primaryGatewayConfig = saltService.getPrimaryGatewayConfig(allGatewayConfigs);
Set<String> gatewayTargets = getGatewayPrivateIps(allGatewayConfigs);
try (SaltConnector sc = saltService.createSaltConnector(primaryGatewayConfig)) {
Map<String, Object> properties = new HashMap<>();
for (KeytabModel keytabModel : keytabModels) {
uploadFileToTargets(sc, gatewayTargets, exitModel, keytabModel.getPath(), keytabModel.getFileName(), keytabModel.getKeytab());
Map<String, String> keytabProps = Map.of("principal", keytabModel.getPrincipal(), "path", keytabModel.getPath() + "/" + keytabModel.getFileName());
properties.put(keytabModel.getService(), keytabProps);
}
SaltPillarProperties saltPillarProperties = new SaltPillarProperties("/kerberos/keytab.sls", Collections.singletonMap("keytab", properties));
OrchestratorBootstrap pillarSave = PillarSave.createCustomPillar(sc, gatewayTargets, saltPillarProperties);
Callable<Boolean> runner = saltRunner.runner(pillarSave, exitCriteria, exitModel);
runner.call();
} catch (Exception e) {
LOGGER.info("Error occurred during keytab upload", e);
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
}
}
Aggregations