use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.
the class CloudConfigValidationActions method cloudConfigValidationAction.
@Bean(name = "VALIDATE_CLOUD_CONFIG_STATE")
public Action<?, ?> cloudConfigValidationAction() {
return new AbstractStackCreationAction<>(StackEvent.class) {
@Override
protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) throws Exception {
ValidateCloudConfigRequest request = new ValidateCloudConfigRequest(payload.getResourceId());
sendEvent(context, request.selector(), request);
}
@Override
protected Object getFailurePayload(StackEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
return new StackFailureEvent(CloudConfigValidationEvent.VALIDATE_CLOUD_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.
the class KerberosConfigValidationActions method checkFreeIpaExistsAction.
@Bean(name = "CHECK_FREEIPA_EXISTS_STATE")
public Action<?, ?> checkFreeIpaExistsAction() {
return new AbstractStackCreationAction<>(StackEvent.class) {
@Override
protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) {
CheckFreeIpaExistsEvent event = new CheckFreeIpaExistsEvent(payload.getResourceId());
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(StackEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction in project cloudbreak by hortonworks.
the class KerberosConfigValidationActions method kerberosConfigValidationAction.
@Bean(name = "VALIDATE_KERBEROS_CONFIG_STATE")
public Action<?, ?> kerberosConfigValidationAction() {
return new AbstractStackCreationAction<>(ValidateKerberosConfigEvent.class) {
@Override
protected void doExecute(StackCreationContext context, ValidateKerberosConfigEvent payload, Map<Object, Object> variables) {
decorateStackWithCustomDomainIfAdOrIpaJoinable(context.getStack());
Cluster cluster = context.getStack().getCluster();
if ((cluster != null && Boolean.TRUE.equals(cluster.getAutoTlsEnabled())) || payload.doesFreeipaExistsForEnv()) {
boolean hasFreeIpaKerberosConfig = clusterCreationEnvironmentValidator.hasFreeIpaKerberosConfig(context.getStack());
if (!hasFreeIpaKerberosConfig) {
throw new IllegalStateException("AutoTLS works only with FreeIPA. No FreeIPA Kerberos configuration is found.");
}
}
sendEvent(context, KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FINISHED_EVENT.selector(), payload);
}
@Override
protected Object getFailurePayload(ValidateKerberosConfigEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
}
private void decorateStackWithCustomDomainIfAdOrIpaJoinable(Stack stack) {
Optional<KerberosConfig> kerberosConfig = measure(() -> kerberosConfigService.get(stack.getEnvironmentCrn(), stack.getName()), LOGGER, "kerberosConfigService get {} ms");
if (kerberosConfig.isPresent() && StringUtils.isNotBlank(kerberosConfig.get().getDomain())) {
LOGGER.info("Setting custom domain [{}] for cluster [{}]", kerberosConfig.get().getDomain(), stack.getName());
stack.setCustomDomain(kerberosConfig.get().getDomain());
stackService.save(stack);
} else {
LOGGER.info("No kerberos config or no custom domain found");
}
}
};
}
Aggregations