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, Boolean detailed, 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);
StackStatus stackStatus = stack.getStackStatus();
CDPStructuredFlowEvent event = new CDPStructuredFlowEvent(operationDetails, flowDetails, null, 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 StackToStackDetailsConverter method convert.
public StackDetails convert(Stack source) {
StackDetails stackDetails = new StackDetails();
stackDetails.setId(source.getId());
stackDetails.setName(source.getName());
stackDetails.setTunnel(source.getTunnel().name());
stackDetails.setRegion(source.getRegion());
stackDetails.setAvailabilityZone(source.getAvailabilityZone());
stackDetails.setCloudPlatform(source.getCloudPlatform());
stackDetails.setPlatformVariant(source.getPlatformvariant());
StackStatus stackStatus = source.getStackStatus();
if (stackStatus != null) {
stackDetails.setStatus(stackStatus.getStatusString());
stackDetails.setDetailedStatus(stackStatus.getDetailedStackStatusString());
stackDetails.setStatusReason(stackStatus.getStatusReason());
}
Set<InstanceGroup> instanceGroups = instanceGroupService.findByStackId(source.getId());
stackDetails.setMultiAz(getMultiAz(instanceGroups));
stackDetails.setInstanceGroups(instanceGroups.stream().map(e -> instanceGroupToInstanceGroupDetailsConverter.convert(e)).collect(Collectors.toList()));
stackDetails.setTags(source.getTags());
convertImage(stackDetails, source);
return stackDetails;
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class StackStatusTest method setUp.
void setUp(int instanceCount) throws Exception {
underTest.setLocalId(STACK_ID.toString());
stack = new Stack();
stack.setId(STACK_ID);
StackStatus stackStatus = new StackStatus();
stackStatus.setDetailedStackStatus(DetailedStackStatus.PROVISIONED);
stack.setStackStatus(stackStatus);
when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
when(flowLogService.isOtherFlowRunning(STACK_ID)).thenReturn(false);
InstanceGroup instanceGroup1 = new InstanceGroup();
Set<InstanceMetaData> instances = new HashSet<>();
if (instanceCount >= 1) {
instances.add(createInstance(INSTANCE_1));
}
if (instanceCount >= 2) {
instances.add(createInstance(INSTANCE_2));
}
if (instanceCount >= 3) {
instances.add(createInstance(INSTANCE_3));
}
instanceGroup1.setInstanceMetaData(instances);
stack.setInstanceGroups(Set.of(instanceGroup1));
notTerminatedInstances = instances;
when(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).thenReturn(notTerminatedInstances);
rpcResponse = new RPCResponse<>();
when(freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(eq(stack), any())).thenReturn(rpcResponse);
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class FreeIpaUpgradeCcmServiceTest method createStack.
private Stack createStack(Status status) {
Stack stack = new Stack();
stack.setId(STACK_ID);
stack.setEnvironmentCrn(ENVIRONMENT_CRN);
stack.setName(STACK_NAME);
stack.setTunnel(Tunnel.CCM);
StackStatus stackStatus = new StackStatus();
stack.setStackStatus(stackStatus);
stackStatus.setStatus(status);
return stack;
}
use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.
the class RepairInstancesServiceTest method createStack.
private Stack createStack(Status stackStatus, List<InstanceStatus> instanceStatuses, int requestedInstancesWithoutInstanceIds) {
Stack stack = new Stack();
stack.setId(STACK_ID);
stack.setEnvironmentCrn(ENVIRONMENT_ID1);
StackStatus s = new StackStatus();
s.setStatus(stackStatus);
stack.setStackStatus(s);
int i = 1;
Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
for (InstanceStatus instanceStatus : instanceStatuses) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceId("i-" + i);
instanceMetaData.setInstanceStatus(instanceStatus);
instanceMetaDataSet.add(instanceMetaData);
i++;
}
for (i = 0; i < requestedInstancesWithoutInstanceIds; i++) {
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
instanceMetaDataSet.add(instanceMetaData);
}
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceMetaData(instanceMetaDataSet);
instanceGroup.setNodeCount(instanceMetaDataSet.size());
stack.setInstanceGroups(Set.of(instanceGroup));
return stack;
}
Aggregations