use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class CreateFullBackupHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<CreateFullBackupEvent> event) {
Stack stack = stackService.getByIdWithListsInTransaction(event.getData().getResourceId());
MDCBuilder.buildMdcContext(stack);
Set<Node> nodes = nodeService.mapInstancesToNodes(stack.getNotDeletedInstanceMetaDataSet());
OrchestratorStateParams stateParameters = createOrchestratorStateParams(stack, nodes);
try {
runBackupForNodesSequentially(nodes, stateParameters);
return new StackEvent(FullBackupEvent.FULL_BACKUP_SUCCESSFUL_EVENT.event(), event.getData().getResourceId());
} catch (CloudbreakOrchestratorFailedException | CloneNotSupportedException e) {
LOGGER.error("Full backup failed for node: {}", stateParameters.getTargetHostNames(), e);
return new StackFailureEvent(FullBackupEvent.FULL_BACKUP_FAILED_EVENT.event(), event.getData().getResourceId(), e);
}
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FlowOperationServiceTest method testGetOperationProgressByResourceCrn.
@Test
public void testGetOperationProgressByResourceCrn() {
// GIVEN
ProvisionFlowEventChainFactory provisionFlowEventChainFactory = new ProvisionFlowEventChainFactory();
FlowTriggerEventQueue eventQueue = provisionFlowEventChainFactory.createFlowTriggerEventQueue(new StackEvent(null, null));
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.FREEIPA, EXPECTED_TYPE_LIST)).willReturn(new OperationView());
// WHEN
underTest.getOperationProgressByEnvironmentCrn(TEST_ENV_CRN, false);
// THEN
verify(operationDetailsPopulator, times(1)).createOperationView(operationFlowsView, OperationResource.FREEIPA, EXPECTED_TYPE_LIST);
// Checks that the number of provision flows are the same as in the operation check
assertEquals(EXPECTED_TYPE_LIST.size(), eventQueue.getQueue().size());
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method upscaleFinsihedAction.
@Bean(name = "UPSCALE_FINISHED_STATE")
public Action<?, ?> upscaleFinsihedAction() {
return new AbstractUpscaleAction<>(StackEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getUpscaleCompleteStatus(variables), "Upscale complete");
if (shouldCompleteOperation(variables)) {
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
successDetails.getAdditionalDetails().put("Hosts", getUpscaleHosts(variables));
operationService.completeOperation(stack.getAccountId(), getOperationId(variables), List.of(successDetails), Collections.emptyList());
}
sendEvent(context, UPSCALE_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method installFreeIpaAction.
@Bean(name = "UPSCALE_FREEIPA_INSTALL_STATE")
public Action<?, ?> installFreeIpaAction() {
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), "Installing FreeIPA");
InstallFreeIpaServicesRequest request = new InstallFreeIpaServicesRequest(stack.getId());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaUpscaleActions method saveMetadataAction.
@Bean(name = "UPSCALE_SAVE_METADATA_STATE")
public Action<?, ?> saveMetadataAction() {
return new AbstractUpscaleAction<>(CollectMetadataResult.class) {
@Override
protected void doExecute(StackContext context, CollectMetadataResult payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Saving metadata");
List<String> instanceIds = payload.getResults().stream().map(CloudVmMetaDataStatus::getCloudVmInstanceStatus).map(CloudVmInstanceStatus::getCloudInstance).map(CloudInstance::getInstanceId).collect(Collectors.toList());
setInstanceIds(variables, instanceIds);
metadataSetupService.saveInstanceMetaData(stack, payload.getResults(), com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus.CREATED);
sendEvent(context, UPSCALE_SAVE_METADATA_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
Aggregations