use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class StackStatusTest method available.
@Test
@DisplayName("GIVEN an available stack " + "WHEN FreeIpa instance is available " + "THEN stack status should not change")
void available() throws Exception {
setUp(1);
setUpFreeIpaAvailabilityResponse(true);
when(stackInstanceProviderChecker.checkStatus(stack, notTerminatedInstances)).thenReturn(List.of(createCloudVmInstanceStatus(INSTANCE_1, com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED)));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
StackStatus stackStatus = new StackStatus();
stackStatus.setDetailedStackStatus(DetailedStackStatus.AVAILABLE);
stack.setStackStatus(stackStatus);
underTest.executeTracedJob(jobExecutionContext);
verify(stackUpdater, never()).updateStackStatus(eq(stack), any(), any());
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class FreeipaStructuredFlowEventFactory method createStructuredFlowEvent.
@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
Stack stack = stackService.getStackById(resourceId);
String resourceType = CloudbreakEventService.FREEIPA_RESOURCE_TYPE;
CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, stack.getId(), stack.getName(), nodeConfig.getId(), serviceVersion, stack.getAccountId(), stack.getResourceCrn(), ThreadBasedUserCrnProvider.getUserCrn(), stack.getEnvironmentCrn(), null);
StackDetails stackDetails = stackToStackDetailsConverter.convert(stack);
StackStatus stackStatus = stack.getStackStatus();
CDPFreeIpaStructuredFlowEvent event = new CDPFreeIpaStructuredFlowEvent(operationDetails, flowDetails, stackDetails, stackStatus.getDetailedStackStatus().name(), stackStatus.getStatusReason());
if (exception != null) {
event.setException(ExceptionUtils.getStackTrace(exception));
}
return event;
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Stack stack, DetailedStackStatus newDetailedStatus, String rawNewStatusReason) {
Status newStatus = newDetailedStatus.getStatus();
StackStatus stackStatus = stack.getStackStatus();
if (!Status.DELETE_COMPLETED.equals(stackStatus.getStatus())) {
rawNewStatusReason = serviceStatusRawMessageTransformer.transformMessage(rawNewStatusReason, stack.getTunnel());
String transformedStatusReason = stackStatusMessageTransformator.transformMessage(rawNewStatusReason);
if (isStatusChanged(stack, newDetailedStatus, transformedStatusReason, newStatus)) {
stack = handleStatusChange(stack, newDetailedStatus, transformedStatusReason, newStatus, stackStatus);
} else {
LOGGER.debug("Statuses are the same, it will not update");
updateInMemoryStoreIfStackIsMissing(stack, newStatus);
}
}
return stack;
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class StackUpdater method saveStackNewStatus.
private Stack saveStackNewStatus(Stack stack, DetailedStackStatus newDetailedStatus, String newStatusReason, Status newStatus, StackStatus stackStatus) {
LOGGER.debug("Updated: status from {} to {} - detailed status from {} to {} - reason from {} to {}", stackStatus.getStatus(), newStatus, stackStatus.getDetailedStackStatus(), newDetailedStatus, stackStatus.getStatusReason(), newStatusReason);
stack.setStackStatus(new StackStatus(stack, newStatus, newStatusReason, newDetailedStatus));
stack = stackService.save(stack);
return stack;
}
Aggregations