use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method tlsSetupAction.
@Bean(name = "UPSCALE_TLS_SETUP_STATE")
public Action<?, ?> tlsSetupAction() {
return new AbstractUpscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Setting up TLS");
StackEvent event;
try {
if (!stack.getTunnel().useCcm()) {
Set<InstanceMetaData> newInstancesMetaData = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getAllInstanceMetaData().stream()).filter(this::isNewInstancesWithoutTlsCert).collect(Collectors.toSet());
for (InstanceMetaData gwInstance : newInstancesMetaData) {
tlsSetupService.setupTls(stack.getId(), gwInstance);
}
}
event = new StackEvent(UpscaleFlowEvent.UPSCALE_TLS_SETUP_FINISHED_EVENT.event(), stack.getId());
} catch (Exception e) {
LOGGER.error("Failed to setup TLS", e);
event = new UpscaleFailureEvent(stack.getId(), "Setting ups TLS", Set.of(), Map.of(), e);
}
sendEvent(context, event.selector(), event);
}
private boolean isNewInstancesWithoutTlsCert(InstanceMetaData instanceMetaData) {
return instanceMetaData.getInstanceStatus().equals(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus.CREATED) && Objects.isNull(instanceMetaData.getServerCert());
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method orchestratorConfig.
@Bean(name = "UPSCALE_ORCHESTRATOR_CONFIG_STATE")
public Action<?, ?> orchestratorConfig() {
return new AbstractUpscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Configuring the orchestrator");
OrchestratorConfigRequest request = new OrchestratorConfigRequest(stack.getId());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method updateClusterProxyRegistrationPreBootstrapAction.
@Bean(name = "UPSCALE_UPDATE_CLUSTERPROXY_REGISTRATION_PRE_BOOTSTRAP_STATE")
public Action<?, ?> updateClusterProxyRegistrationPreBootstrapAction() {
return new AbstractUpscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Update cluster proxy registration before bootstrap");
List<String> instanceIds = getInstanceIds(variables);
Set<InstanceMetaData> newInstances = instanceMetaDataService.getByInstanceIds(stack.getId(), instanceIds);
boolean allNewInstanceHasFqdn = newInstances.stream().allMatch(im -> StringUtils.isNotBlank(im.getDiscoveryFQDN()));
Selectable event = allNewInstanceHasFqdn ? new ClusterProxyRegistrationRequest(stack.getId()) : new ClusterProxyRegistrationSuccess(stack.getId());
sendEvent(context, event.selector(), event);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method startingAction.
@Bean(name = "UPSCALE_STARTING_STATE")
public Action<?, ?> startingAction() {
return new AbstractUpscaleAction<>(UpscaleEvent.class) {
@Override
protected void doExecute(StackContext context, UpscaleEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
String operationId = payload.getOperationId();
setOperationId(variables, operationId);
setInstanceCountByGroup(variables, payload.getInstanceCountByGroup());
setRepair(variables, payload.isRepair());
setChainedAction(variables, payload.isChained());
setFinalChain(variables, payload.isFinalChain());
LOGGER.info("Starting upscale {}", payload);
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Starting upscale");
sendEvent(context, UPSCALE_STARTING_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method selectionAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_SELECTION")
public Action<?, ?> selectionAction() {
return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {
@Override
protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Selecting the primary gateway");
List<String> repairInstanceIds = getInstanceIds(variables);
ChangePrimaryGatewaySelectionRequest request = new ChangePrimaryGatewaySelectionRequest(stack.getId(), repairInstanceIds);
sendEvent(context, request);
}
};
}
Aggregations