Search in sources :

Example 1 with StackStatus

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;
}
Also used : CDPStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 2 with StackStatus

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;
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 3 with StackStatus

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);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) HashSet(java.util.HashSet)

Example 4 with StackStatus

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;
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 5 with StackStatus

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;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Aggregations

StackStatus (com.sequenceiq.freeipa.entity.StackStatus)24 Stack (com.sequenceiq.freeipa.entity.Stack)17 DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)14 Test (org.junit.jupiter.api.Test)9 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)5 InstanceStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus)5 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)3 Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)3 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 HashSet (java.util.HashSet)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)1